Reputation: 507
I am working on a text mining process and using Random forest to classify text to categories. I am using caret package after processing my text. I split the data to train and test, Below is the R code after the same:
traindata <- tdm_df[s,] # training set
testdata <- tdm_df[-s,] # testing set
rf.tfidf <- train(traindata[,c(1:69)], train[,70],
method = "rf", trControl = ctrl) # train random forest
rf.tfidf
When I run the last line, I get the below error:
Error in `[.data.frame`(train, , c(1:56)) : undefined columns selected
Edit 1: next error after correction:
Error in train[1:5, ] : object of type 'closure' is not subsettable
I see the term_sparse is giving me an issue and may be the text mining part, how can i improve my outcome?
Not sure what the issue is. Please help out!
Upvotes: 0
Views: 135
Reputation: 3116
Replace train[,70]
with traindata[,70]
:
rf.tfidf <- train(traindata[,c(1:69)], traindata[,70],
method = "rf", trControl = ctrl)
Upvotes: 1