Creates a word cloud of words from all excerpts where a given code is applied. Common English stop words, user-supplied stop words, and punctuation are removed.
Arguments
- data
A data.frame or tibble containing at least one
excerptcolumn and one or more code columns starting with"c_".- code
A string giving the name of the code column to filter on (e.g. "c_belonging").
- max_words
Maximum number of words to display in the word cloud (default = 100).
- custom_stopwords
A character vector of additional stop words to remove (default =
NULL).
Examples
library(dplyr)
df <- tibble::tibble(
excerpt = c(
"I felt connected to peers and friends.",
"We should normalize conversations about mental health.",
"My teachers helped me belong at school.",
"I am comfortable talking about suicide prevention."
),
c_belonging = c(TRUE, FALSE, TRUE, FALSE),
c_destigmatization = c(FALSE, TRUE, FALSE, FALSE)
)
# Word cloud for belonging excerpts
wordcloud(df, "c_belonging")
# With custom stop words
wordcloud(df, "c_belonging", custom_stopwords = c("connected", "school"))
