我想转换与tm
包TermDocumentMatrix()
创建以下简单的三重态基质从类转换“simple_triplet_matrix”上课“矩阵”
A term-document matrix (317443 terms, 86960 documents)
Non-/sparse entries: 18472230/27586371050
Sparsity : 100%
Maximal term length: 653
Weighting : term frequency (tf)
类
[1] "TermDocumentMatrix" "simple_triplet_matrix"
到一个密集矩阵。
但
dense <- as.matrix(tdm)
生成错误
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
我实在无法理解的错误和警告消息。尝试在一个小数据集上复制错误与
library(tm)
data("crude")
tdm <- TermDocumentMatrix(crude)
as.matrix(tdm)
不会产生相同的问题。我从this answer中看到类似的问题通过slam
包得到了解决(即使问题是关于总和操作而不是转换成密集矩阵)。我浏览了slam
文档,但我找不到任何特定功能将simple_triplet_matrix
类的对象转换为matrix
类的对象。
行数乘以列数'nr * nc'对于可用存储空间来说太大。 –