"RTextTools"create_matrix出错了

Way*_*nja 12 r classification text-mining

我正在运行RTextTools包来构建文本分类模型.

当我准备预测数据集并尝试将其转换为矩阵时.我得到错误:

Error in if (attr(weighting, "Acronym") == "tf-idf") weight <- 1e-09 : 
  argument is of length zero
Run Code Online (Sandbox Code Playgroud)

我的代码如下:

table<-read.csv("traintest.csv",header = TRUE)
dtMatrix <- create_matrix(table["COMMENTS"])
container <- create_container(dtMatrix, 
                              table$LIKELIHOOD_TO_RECOMMEND, 
                              trainSize=1:5000,testSize=5001:10000, 
                              virgin=FALSE)
model <- train_model(container, "SVM", kernel="linear", cost=1)

predictionData<-read.csv("rest.csv",header = TRUE)
**predMatrix <- create_matrix(predictionData["COMMENTS"],originalMatrix=dtMatrix)**
Error in if (attr(weighting, "Acronym") == "tf-idf") weight <- 1e-09 : 
      argument is of length zero
Run Code Online (Sandbox Code Playgroud)

错误是由最后一个代码(粗体)给出我尝试在谷歌搜索但没有看到一个明确的解决方案.

谢谢

小智 36

运行这个:

trace("create_matrix",edit=T)
Run Code Online (Sandbox Code Playgroud)

在弹出的源代码框中,第42行将拼写错误的单词"acronym".将"A"更改为"a"并点击"保存" - 之后应该可以正常工作.