Reputation: 629
Whenever I run glmnet(mpg ~ ., data = mtcars, alpha=1)
(from the glmnet
package) I get the following error:
"Error in glmnet(mpg ~ ., data = mtcars, alpha = 1) : unused argument (data = mtcars)"
Any ideas for how to deal with this?
I think its because the glmnet() function is supposed to take in x and y as separate arguments. If I need separate x and y arguments, how would I write the formula so that glmnet::glmnet()
runs for all variables of mtcars
?
Upvotes: 0
Views: 318
Reputation: 40628
As the commenter suggests you need to use the glmnet
method like so:
fit <- glmnet(as.matrix(mtcars[-1]), mtcars$mpg, alpha=1)
plot(fit)
Upvotes: 1