dtm_reverse: Inverse operation of the document_term_matrix function

View source: R/nlp_flow.R

dtm_reverseR Documentation

Inverse operation of the document_term_matrix function

Description

Inverse operation of the document_term_matrix function. Creates frequency table which contains 1 row per document/term

Usage

dtm_reverse(x)

Arguments

x

an object as returned by document_term_matrix

Value

a data.frame with columns doc_id, term and freq where freq is just the value in each cell of the x

See Also

document_term_matrix

Examples

x <- data.frame(
 doc_id = c(1, 1, 2, 3, 4), 
 term = c("A", "C", "Z", "X", "G"), 
 freq = c(1, 5, 7, 10, 0))
dtm <- document_term_matrix(x)
dtm_reverse(dtm)

udpipe documentation built on Jan. 6, 2023, 5:06 p.m.