Topic-model top-terms plot: faceted bars, one facet per topic
Source:R/plots.R
sframe_plot_topics.RdServes both sframe_run_topic_model_lda() and sframe_run_stm_topics()
results with no dispatch on result$test: both runners emit a $table
with the same topic/term/beta columns (LDA's beta from
tidytext::tidy(), STM's from its fitted word-topic distribution), so
this function reads that shared shape directly.
Usage
sframe_plot_topics(result, palette = c("web", "print"))Arguments
- result
A
topic_model_ldaorstm_topicsresult list fromrun_analysis_plan().- palette
One of
"web"or"print". Seesframe_brand().
Examples
# \donttest{
if (requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("stm", quietly = TRUE) &&
requireNamespace("tidytext", quietly = TRUE)) {
demo <- sframe_demo("open_text")
res <- run_analysis_plan(demo$responses, demo$instrument)
sframe_plot_topics(res$RQ10)
}
#> Warning: K=2 is equivalent to a unidimensional scaling model which you may prefer.
# }