1

我第一次使用 RTextTools。这是我的 create_matrix 代码

library(RTextTools)
texts <- c("This is the first document.", 
          "Is this a text?", 
        "This is the second file.", 
        "This is the third text.", 
        "File is not this.") 
doc_matrix <- create_matrix(texts, language="english", removeNumbers=FALSE, stemWords=TRUE, removeSparseTerms=.2)

我收到以下错误:

Error in `[.simple_triplet_matrix`(matrix, , sort(colnames(matrix))) : 
Invalid subscript type: NULL.
In addition: Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(j) : is.na() applied to non-(list or vector) of type 'NULL'

我还没有看到其他人发布此错误,并且认为我缺少一些非常基本的东西。

彼得

4

2 回答 2

1

您需要removeSparseTerms=.2)tm包文档中删除最后一个参数removeSparseTerms:“一个术语文档矩阵,其中删除了 x 中的那些术语,这些术语至少具有稀疏百分比的空(即,术语在文档中出现 0 次)元素。即,得到的矩阵只包含稀疏因子小于稀疏的项。”

我认为稀疏阈值对于您的数据集来说太低了。

于 2015-01-23T13:57:51.170 回答
-1
doc_matrix <- create_matrix(texts, language="english", removeNumbers=FALSE, stemWords=TRUE, removeSparseTerms=.9999)
于 2017-03-03T07:50:46.200 回答