Description Usage Arguments Examples
This is a convenient function to create term-term matrix from document-term matrix, term-document matrix, or a matrix that represents one of the two. Sparse matrix is used to speed up computing. The output can be either a matrix or a sparse matrix.
1 | create_ttm(x, type = "dtm", tomatrix = FALSE, checks = TRUE)
|
x |
an object of class DocumentTermMatrix or TermDocumentMatrix, or a matrix which has its rownames or colnames as terms. |
type |
if |
tomatrix |
should be logical, whether to output a matrix result. If |
checks |
if |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | x <- c(
"Hello, what do you want to drink?",
"drink a bottle of milk",
"drink a cup of coffee",
"drink some water")
dtm <- corp_or_dtm(x, from = "v", type = "dtm")
ttm1 <- create_ttm(dtm)
ttm2 <- create_ttm(dtm, tomatrix = TRUE)
tdm <- t(dtm)
ttm3 <- create_ttm(tdm)
ttm_sparse <- ttm3[[1]]
ttm_ordinary <- as.matrix(ttm_sparse)
colnames(ttm_ordinary) <- ttm3[[2]]
rownames(ttm_ordinary) <- ttm3[[2]]
# You can also use Matrix::writeMM(ttm_sparse, filename)
# to write it on your disk.
|
CHECKING ARGUMENTS
PROCESSING CHARACTER VECTOR
GENERATING CORPUS
PROCESSING CORPUS
MAKING DTM/TDM
DONE
Warning messages:
1: In Sys.setlocale(category = "LC_COLLATE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
2: In Sys.setlocale(category = "LC_CTYPE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
Warning messages:
1: In Sys.setlocale(category = "LC_COLLATE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
2: In Sys.setlocale(category = "LC_CTYPE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
Warning messages:
1: In Sys.setlocale(category = "LC_COLLATE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
2: In Sys.setlocale(category = "LC_CTYPE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
Warning messages:
1: In Sys.setlocale(category = "LC_COLLATE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
2: In Sys.setlocale(category = "LC_CTYPE", s_right_locale) :
OS reports request to set locale to "zh_CN.UTF-8" cannot be honored
Warning message:
system call failed: Cannot allocate memory
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.