【问题标题】:Rtexttools Trouble creating document term matrix with create_matrixRtexttools 使用 create_matrix 创建文档术语矩阵时遇到问题
【发布时间】:2015-03-22 12:49:35
【问题描述】:

我是第一次使用 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'

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

彼得

【问题讨论】:

    标签: r supervised-learning


    【解决方案1】:
    doc_matrix <- create_matrix(texts, language="english", removeNumbers=FALSE, stemWords=TRUE, removeSparseTerms=.9999)
    

    【讨论】:

      【解决方案2】:

      您需要从removeSparseTerms 上的tm 包文档中删除最后一个参数removeSparseTerms=.2):“一个术语文档矩阵,其中从x 中删除的那些术语至少具有稀疏百分比的空(即, 词条在文档中出现 0 次) 元素。即,生成的矩阵仅包含稀疏因子小于稀疏的词条。"

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-14
        • 1970-01-01
        • 1970-01-01
        • 2015-12-07
        相关资源
        最近更新 更多