I have a data set that I’m trying to use rfe() from the caret package in R on.
x is the prices I’m trying to predict.
y is the variables I’m using to make the prediction.
I can’t get rfe to stop giving the following error message:
> lmProfile2 <- rfe(x1,y1,
+ sizes = subsets,
+ rfeControl = ctrl)
Error in rfe.default(x1, y1, sizes = subsets, rfeControl = ctrl) :
there should be the same number of samples in x and y
Here’s some info:
> class(x1)
[1] "data.frame"
> class(y1)
[1] "data.frame"
> nrow(x1)
[1] 500
> nrow(y1)
[1] 500
> ncol(x1)
[1] 68
> ncol(y1)
[1] 1
Also:
> y1 <- data.frame(y = tiny4[,2])
> x1 <- data.frame(tiny4[,-c(1,2)])
> subsets <- c(5,10)
>
> ctrl <- rfeControl(functions = lmFuncs,
+ method = "cv",
+ verbose = FALSE,
+ returnResamp = "final")
>
Any idea why I’m getting the message?
yshould be a numeric or factor vector. Here you have it as a data frame. Compare:vs.