Categorical predictors with matrix.model for cv.glmnet

Hi,

I'm new to R, and I'm currently trying to run a multinomial LASSO regression. All my predictors are categorical, so I tried to use matrix.model to create the matrix of predictors and I expected the command to automatically split the regressors into dummies. However, the predictors in the matrix still remain categorical. Here is the simple code:

#Create x matrix and y vector
x <- model.matrix(Y~., Lasso) [, -1]
y <- Lasso$Y

Am I missing something? Do you know what the problem might be? Thanks!

Try using tidymodels for this. Here is a worked example for you. We take care of the data processing steps for you.