【发布时间】:2014-03-22 04:47:40
【问题描述】:
所以我有一个非常大的术语文档矩阵:
> 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
我怎样才能在这个对象上得到一个简单的行总和?谢谢!!
【问题讨论】:
标签: r text-mining