This is one way to use it:
explanation of the parameters is as follows:
x is a matrix (of predictors). model.matrix() turns a dataframe into a matrix.
y is a vector (the response variable)
alpha :you need to set this to 0 for ridge regression and 1 for lasso. You can also set it to a value between 0 and 1.
s: you can set this to ‘lambda.min’ or ‘lambda.1se’. If you set it to lambda.min then the regularization parameter is set to value which shows the minimum error on cross validation (done automatically by glmnet as your model is based on cv.glmnet). If you set it at ‘lambda.1se’ then it is set at one standard error higher than that required for minimum error.