View source: R/topic_visualization.R
gen_topic_clouds | R Documentation |
This function creates a word cloud for each topic.
gen_topic_clouds(model_output, n = 50)
model_output |
The output from model_topics function |
n |
The number of top terms to include in the word cloud |
A list of ggplot objects, where each element represents a word cloud for a topic.
# Create a temporary file with sample book IDs
temp_file <- tempfile(fileext = ".txt")
writeLines(c("1420", "2767052", "10210"), temp_file)
# Scrape reviews
reviews <- scrape_reviews(temp_file, num_reviews = 30, use_parallel = FALSE)
# Model topics
topic_results <- model_topics(reviews, num_topics = 3, num_terms = 50, english_only = TRUE)
# Generate word clouds for each topic
wordcloud_plots <- gen_topic_clouds(topic_results, n = 20)
# Display the word cloud for the first topic
if (interactive()) {
print(wordcloud_plots[[1]])
}
# Clean up: remove the temporary file
file.remove(temp_file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.