Generate a Word Cloud from Flow Descriptions
Source:R/analysis_wordcloud_from_flows.R
analysis_wordcloud_from_flows.RdAggregates flow descriptions, cleans the text, and generates a word cloud. Optionally facets the word cloud generation by budget year.
Usage
analysis_wordcloud_from_flows(
flows,
facet_by_year = FALSE,
min_freq = 5,
max_words = 100,
stopwords = c("project", "response", "support", "activities", "million", "allocation",
"reserve", "usd", "flow", "end", "start", "standard", "date", "code", "type",
"humanitarian", "region", "plan", "humanitaire", "r<c3><a9>ponse")
)Arguments
- flows
Dataframe
flows.- facet_by_year
Logical scalar: If TRUE, returns a list of word clouds, one for each unique budget year. If FALSE, returns a single word cloud from all descriptions combined.
- min_freq
Integer: Minimum frequency of a word to be included in the cloud.
- max_words
Integer: Maximum number of words to display in the cloud.
- stopwords
Character vector: Additional words to remove (beyond standard English stopwords).
Value
A wordcloud2 object (if facet_by_year=FALSE) or a named list of wordcloud2 objects (if facet_by_year=TRUE).
Examples
analysis_wordcloud_from_flows(flows, facet_by_year = FALSE)
# Returns a named list of word cloud objects
yearly_clouds <- analysis_wordcloud_from_flows(flows, facet_by_year = TRUE)
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
# To view the cloud for a specific year
print(yearly_clouds[["2015"]])
print(yearly_clouds[["2024"]])
print(yearly_clouds[["2025"]])