Subscript out of bounds error in caret's rfe function

Viewed 267

I am trying to use Caret's rfe function to do feature selection. My code worked not even a few days ago. Now I am getting a subscript of of bounds error. The weird part is I can run the rfe function with some built in data from another package no problem, which to me means that this is likely an issue with my data (but I can't figure out what). Any suggestions??

WORKS

load the library

library(mlbench)
library(caret)
library(randomForest)

load the data

data(PimaIndiansDiabetes)

define the control using a random forest selection function

control <- rfeControl(functions=rfFuncs2, method="cv", number=10)

run the RFE algorithm

results <- rfe(PimaIndiansDiabetes[,1:8], PimaIndiansDiabetes[,9], sizes=c(1:8), rfeControl=control)

DOESN'T WORK

results<-rfe(stores[,10:33], stores[,8],sizes=c(1:24), rfeControl=control)

My dataframe "stores" is a bunch of continuous variables (10:33), and a grouping variable (8)

Any Thoughts?

Error Message

1 Answers

I meet the same problem, you can try as.factor(unlist(stores[,8]))

Related