Description Usage Arguments Details Value See Also Examples
Converts LDA topic model to LDAvis compatible json string and starts server.
May require servr
Package to run properly. For conversion of STM topic models use toLDAvis.
1 |
fitted |
Fitted LDA Model. Object of class LDA) |
corpus |
Document corpus. Object of class corpus) |
doc_term |
document term matrix (dtm). |
Beware that to_ldavis
might fail if the corpus contains documents that consist ONLY of numbers,
emojis or punctuation e.g. do not contain a single character string. This is due to a limitation in the topicmodels
package
used for model fitting that does not consider such terms as words and omits them causing the posterior to differ in length from the corpus.
If you encounter such an error, redo your pre-processing and exclude emojis, punctuation and numbers.
When using pool_tweets
you can remove emojis by specifying remove_emojis = TRUE
.
Invisible Object (see serVis)).
toLDAvis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
library(Twitmo)
# load tweets (included in package)
mytweets <- load_tweets(system.file("extdata", "tweets_20191027-141233.json", package = "Twitmo"))
# Pool tweets into longer pseudo-documents
pool <- pool_tweets(data = mytweets)
pooled_dfm <- pool$document_term_matrix
pooled_corp <- pool$corpus
# fit your LDA model with 7 topics
model <- fit_lda(pooled_dfm, n_topics = 7, method = "Gibbs")
# Explore your topics with LDAvis
to_ldavis(model, pooled_corp, pooled_dfm)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.