Сумма строки для большой матрицы срочных документов / simple_triplet_matrix ?? {тм пакет}
Итак, у меня есть очень большая матрица терм-документов:
> class(ph.DTM)
[1] "TermDocumentMatrix" "simple_triplet_matrix"
> ph.DTM
A term-document matrix (109996 terms, 262811 documents)
Non-/sparse entries: 3705693/28904453063
Sparsity : 100%
Maximal term length: 191
Weighting : term frequency (tf)
Как я могу получить rowSum (частоту) каждого термина? Я старался:
> apply(ph.DTM, 1, sum)
Error in vector(typeof(x$v), nr * nc) : vector size cannot be NA
In addition: Warning message:
In nr * nc : NAs produced by integer overflow
Очевидно, я знаю оremoveSparseTerms
:
ph.DTM2 <- removeSparseTerms(ph.DTM, 0.99999)
Что немного уменьшает размер:
> ph.DTM2
A term-document matrix (28842 terms, 262811 documents)
Non-/sparse entries: 3612620/7576382242
Sparsity : 100%
Maximal term length: 24
Weighting : term frequency (tf)
Но я все еще не могу применить какие-либо связанные с матрицей функции к нему:
> as.matrix(ph.DTM2)
Error in vector(typeof(x$v), nr * nc) : vector size cannot be NA
In addition: Warning message:
In nr * nc : NAs produced by integer overflow
Как я могу просто получить сумму простых строк на этот объект? Спасибо!!