Skip to contents

plot_topic_wordcloud() prepares, saves, and displays word clouds of topics in a topic model. The function can display word clouds of one or more specific topics, or it can show word clouds for every topic.

Usage

plot_topic_wordcloud(lda, topics = NULL, crop = TRUE, savedir = "plots")

Arguments

lda

The topic model to be used.

topics

Topic numbers to be visualized. If left undefined, all topics will be visualized

crop

Whether to remove white space from visualized word clouds

savedir

The directory to save plots in. Defaults to "plots"

Value

Graphic(s) prepared with knitr for Quarto or RMarkdown

Examples

austen <-
  get_gutenberg_corpus(c(105, 121, 141, 158, 161, 946, 1342)) |>
  dplyr::select(doc_id = title, text)

austen_lda <-
  austen |>
  make_topic_model(k = 30)

austen_lda |>
  plot_topic_wordcloud(topic = 6)