I have a question about R code...
I am having a problem when I try to add features into my model. Our professor gave us some code to do lasso regression on Magic The Gathering card prices. If I run his code as is it will work. Whenever I try to add another column as a feature into his code I have problems.
Here is the error: "Error in cbind2(1, newx) %*% nbeta : Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 90"
A screenshot of my command line And then if I drop some of the columns in the larger training dataset then I still get the same error.
After making the data frames the same # of columns
As I run through the code, I check the dimensions of the data frames 'test' and 'train' and I figured out which lines are changing the test and train data frames.
These lines:
dummies <- dummyVars(future_price ~ ., data = train)
train<-predict(dummies, newdata = train)
test<-predict(dummies, newdata = test)
So, before running these lines, both the train and test data set have exactly 23 variables (columns). After running these three dummy lines, the test data set has 41 columns, and the training data set has 47 columns. I don't really understand how a different number of columns get added to each data frame if the lines of code are the same besides substituting 'train' and 'test'.
Please help! Thanks.