I am doing lasso with glmnet
in R. I have the lasso coefs out$beta
Input:
x1 0.5744207722
x2 -0.3575682570
x3 -0.0995794334
How can I extract the name of the variables?
Desired output:
x1, x2,x3
What I tried
$
as.data.frame
as.matrix
but none of them convert the coefs
into a n row 2 columns matrix. They remain as a vector, x1 0.5744207722
.
I cannot do it manually. I have more than 1000 variables and more models to run. And I don't won't to write it on my disk, and read it back.