fit_stm | R Documentation |
Estimate a structural topic model
fit_stm( data, n_topics = 2L, xcov, remove_punct = TRUE, stem = TRUE, remove_url = TRUE, remove_emojis = TRUE, stopwords = "en", ... )
data |
Data frame containing tweets and hashtags. Works with any data frame, as long as there
is a "text" column of type character string and a "hashtags" column with comma separated character vectors.
Can be obtained either by using |
n_topics |
Integer with number of topics. |
xcov |
Either a \[stats]formula with an empty left-hand side specifying external covariates
(meta data) to use.e.g. |
remove_punct |
Logical. Indicates whether punctuation (includes Twitter hashtags and usernames) should be removed. Defaults to TRUE. |
stem |
Logical. If |
remove_url |
Logical. If |
remove_emojis |
Logical. If |
stopwords |
a character vector, list of character vectors, dictionary or collocations object. See pattern for details. Defaults to stopwords("english"). |
... |
Additional arguments passed to stm. |
Use this to function estimate a STM from a data frame of parsed Tweets. Works with unpooled Tweets only. Pre-processing and fitting is done in one run.
Object of class stm. Additionally, pre-processed documents are appended into a named list called "prep".
stm
## Not run: library(Twitmo) # load tweets (included in package) mytweets <- load_tweets(system.file("extdata", "tweets_20191027-141233.json", package = "Twitmo")) # fit STM with tweets stm_model <- fit_stm(mytweets, n_topics = 7, xcov = ~ retweet_count + followers_count + reply_count + quote_count + favorite_count, remove_punct = TRUE, remove_url = TRUE, remove_emojis = TRUE, stem = TRUE, stopwords = "en" ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.