tidy.tidylda {tidylda} | R Documentation |
Tidy a matrix from a tidylda
topic model
Description
Tidy the result of a tidylda
topic model
Usage
## S3 method for class 'tidylda'
tidy(x, matrix, log = FALSE, ...)
## S3 method for class 'matrix'
tidy(x, matrix, log = FALSE, ...)
Arguments
x |
an object of class |
matrix |
the matrix to tidy; one of |
log |
do you want to have the result on a log scale? Defaults to |
... |
other arguments passed to methods,currently not used |
Value
Returns a tibble
.
If matrix = "beta"
then the result is a table of one row per topic
and token with the following columns: topic
, token
, beta
If matrix = "theta"
then the result is a table of one row per document
and topic with the following columns: document
, topic
, theta
If matrix = "lambda"
then the result is a table of one row per topic
and token with the following columns: topic
, token
, lambda
Functions
-
tidy(matrix)
: Tidy an individual matrix. Useful for predictions and called from tidy.tidylda
Note
If log = TRUE
then "log_" will be appended to the name of the third
column of the resulting table. e.g "beta
" becomes "log_beta
".
Examples
dtm <- nih_sample_dtm
lda <- tidylda(data = dtm, k = 10, iterations = 100, burnin = 75)
tidy_beta <- tidy(lda, matrix = "beta")
tidy_theta <- tidy(lda, matrix = "theta")
tidy_lambda <- tidy(lda, matrix = "lambda")