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 に答える