Karl Tian Karl Tian - 6 months ago 109
R Question

"RTextTools" create_matrix got an error

I was running RTextTools package to build a text classification model.

And when I prepare the prediction dataset and tried to transform it in to matrix. I got error as:

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

My code is as below:

table<-read.csv("traintest.csv",header = TRUE)
dtMatrix <- create_matrix(table["COMMENTS"])
container <- create_container(dtMatrix,
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

The error was given by the last code (bold)
I tried search on google but didn't see one clear solution.



Run this:


In the source code box that pops up, line 42 will have a misspelling of the word "acronym". Change the "A" to an "a" and hit "Save" - it should work fine after that.