Browse LDA Topic Models

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.

Installing

if (!require(devtools)) {install.packages("devtools"); library(devtools)}
install_github("vanatteveldt/topicbrowser")
library(topicbrowser)

Creating a topic browser

To create a topic browser, you need to have:

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



vanatteveldt/topicbrowser documentation built on May 3, 2019, 2:59 p.m.