I am doing homework in R for my stats class and I was given these codes to put into R.
library(leaps)
subset.output = regsubsets(y~x1+x2+...+x_p, data = name of data set, nbest = 1)
so with my variables I did the first step and then I entered this code into R
subset.output=regsubsets(SuggestedRetailPrice~HorsePower+DealerCost+HighwayMPG+Weight+WheelBase,data=car.data,nbest=1)
When I put that into R, this error pops up
Error in as.data.frame.default(data) :
cannot coerce class ‘"lm"’ to a data.frame
I have no idea what I'm doing wrong and my teacher isn't helping me, can someone please help me?