| convert-wrappers | R Documentation |
To make the usage as consistent as possible with other packages, quanteda
also provides shortcut wrappers to convert(), designed to be
similar in syntax to analogous commands in the packages to whose format they
are converting.
dfm2austin(x)
dfm2tm(x, weighting = tm::weightTf)
dfm2lda(x, omit_empty = TRUE)
dtm2lda(x, omit_empty = TRUE)
dfm2dtm(x, omit_empty = TRUE)
dfm2stm(x, docvars = NULL, omit_empty = TRUE)
x |
the dfm to be converted |
weighting |
a tm weight, see |
omit_empty |
logical; if |
docvars |
optional data.frame of document variables used as the
|
dfm2lda provides converts a dfm into the list representation
of terms in documents used by the lda package (a list with components
"documents" and "vocab" as needed by
lda::lda.collapsed.gibbs.sampler()).
dfm2ldaformat provides converts a dfm into the list
representation of terms in documents used by the lda package (a list
with components "documents" and "vocab" as needed by
lda::lda.collapsed.gibbs.sampler()).
A converted object determined by the value of to (see above).
See conversion target package documentation for more detailed descriptions
of the return formats.
Additional coercion methods to base R objects are also available:
[as.data.frame](x)converts a dfm into a data.frame
[as.matrix](x)converts a dfm into a matrix
dfmat <- corpus_subset(data_corpus_inaugural, Year > 1970) |>
tokens() |>
dfm()
## Not run:
# shortcut conversion to lda package list format
identical(quanteda:::dfm2lda(dfmat), convert(dfmat, to = "lda"))
## End(Not run)
## Not run:
# shortcut conversion to lda package list format
identical(dfm2ldaformat(dfmat), convert(dfmat, to = "lda"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.