topWords | R Documentation |
Identifies training words (features) most associated with each class in the training data.
topWords(est, latexfile = FALSE, filename = "topwords.tex")
est |
The output object from |
latexfile |
Logical indicating whether the user wants a latex table of results output into the current working directory. |
filename |
String name for the output file. Defaults to |
A dataframe with one row for each class. Columns correspond to class name and the top five words associated with the respective class.
Latex table outputs depend on the Latex packages: longtable and xcolor. Include the lines:
\usepackage\[table\]{xcolor}
\usepackage{longtable}
in the Latex header
Matt W. Loftis
## Load data and create document-feature matrices
train_corpus <- quanteda::corpus(x = training_agendas$text)
train_matrix <- quanteda::dfm(train_corpus,
language = "danish",
stem = TRUE,
removeNumbers = FALSE)
est <- trainNB(training_agendas$coding, train_matrix)
words <- topWords(est)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.