This turns a "tidy" one-term-per-document-per-row data frame into a DocumentTermMatrix or TermDocumentMatrix from the tm package, or a dfm from the quanteda package. These functions support non-standard evaluation through the tidyeval framework. Groups are ignored.
cast_tdm(data, term, document, value, weighting = tm::weightTf, ...) cast_dtm(data, document, term, value, weighting = tm::weightTf, ...) cast_dfm(data, document, term, value, ...)
Table with one-term-per-document-per-row
Column containing terms as string or symbol
Column containing document IDs as string or symbol
Column containing values as string or symbol
The weighting function for the DTM/TDM (default is term-frequency, effectively unweighted)
Extra arguments passed on to
are passed by expression and support quasiquotation;
you can unquote strings and symbols.