m2doc {chinese.misc} | R Documentation |
Rewrite Terms and Frequencies into Many Files
Description
Given a matrix representing a document term matrix, this function takes each row as term frequencies for one file, and rewrite each row as a text. Some text mining tools other than R accept segmented Chinese texts. If you already convert texts into a matrix, you can use this function to convert it into texts, corpus or create document term matrix again.
Usage
m2doc(m, checks = FALSE)
Arguments
m |
a numeric matrix, data frame is not allowed. It must represent a document term
matrix, rather than a term document matrix. Each row of the matrix represents a text. The
matrix should have column names as terms to be written, but if it is |
checks |
should be |
Value
a character vector, each element is a text with repeated
terms (by rep
) linked by a space.
Examples
s <- sample(1:5, 20, replace = TRUE)
m <- matrix(s, nrow = 5)
colnames(m) <- c("r", "text", "mining", "data")
m2doc(m)