Analyze and visualize word frequency trends over time for a fixed term column.
Usage
word_frequency_trends(
dfm_object,
stm_model,
time_variable,
selected_terms,
height = 500,
width = 1000
)
Arguments
- dfm_object
A quanteda document-feature matrix (dfm).
- stm_model
An STM model object.
- time_variable
The column name for the time variable (e.g., "year").
- selected_terms
A vector of terms to analyze trends for.
- height
The height of the resulting Plotly plot, in pixels. Defaults to
500
.- width
The width of the resulting Plotly plot, in pixels. Defaults to
1000
.
Examples
if (interactive()) {
df <- TextAnalysisR::SpecialEduTech
united_tbl <- TextAnalysisR::unite_text_cols(df, listed_vars = c("title", "keyword", "abstract"))
tokens <- TextAnalysisR::preprocess_texts(united_tbl, text_field = "united_texts")
dfm_object <- quanteda::dfm(tokens)
stm_15 <- TextAnalysisR::stm_15
TextAnalysisR::word_frequency_trends(dfm_object,
stm_model = stm_15,
time_variable = "year",
selected_terms = c("calculator", "computer"),
height = 500,
width = 1000)
}