Error using RandomForest

I am trying to use Random Forest to improve the classification to determine if it's profit or not.

ssdata_idx = createDataPartition(ssdata1$Profitable, p = 0.70, list = FALSE)
ssdata_trn = ssdata1[ssdata_idx, ] #Training
ssdata_tst = ssdata1[-ssdata_idx, ] #test
profit.f=randomForest(Profitable~Discount+Sales,subset = ssdata_trn,mtry=3,ntree=1000,importance=TRUE)

Error in xj[i] : invalid subscript type 'list'
I don't know why???


*Error in UseMethod("importance") : *

  • no applicable method for 'importance' applied to an object of class "rpart"*


*Error in varImpPlot(profit.f) : *

  • This function only works for objects of class `randomForest'*

confusionMatrix(predict.tree,as.factor(ssdata_tst$Profitable))emphasized text


Welcome to the RStudio community!

In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue. Once we have that, we can go from there. For help on creating a Reprex, see this guide:

Good luck!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.