dtm_colsums {udpipe} | R Documentation |
Column sums and Row sums for document term matrices
dtm_colsums(dtm) dtm_rowsums(dtm)
dtm |
an object returned by |
a vector of row/column sums with corresponding names
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) x <- dtm_colsums(dtm) x x <- dtm_rowsums(dtm) head(x)