This package allows you to create a set of HTML files to browse a topic model. It creates a word cloud and time-graph per topic, and annotates a selection of documents with the topic for each word.
See the the example for a collection of State of the Union addresses.
if (!require(devtools)) {install.packages("devtools"); library(devtools)} install_github("vanatteveldt/topicbrowser") library(topicbrowser)
To create a topic browser, you need to have:
topicmodels::LDA
The provided data file 'sotu' contains this data from the state of the union addresses. Make sure that the tokens are ordered in the way they appeared in the article
data(sotu) tokens = tokens[order(tokens$aid, tokens$id), ] class(m) head(tokens) head(meta)
With these data, you can create a topic browser as follows:
output = createTopicBrowser(m, tokens$lemma, tokens$aid, words=tokens$word, meta=meta)
You can also publish the output file directly using markdown::rpubsupload
:
library(markdown) result = rpubsUpload("Example topic browser", output) browseURL(result$continueUrl)
This produces the results shown in the the example
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.