I intend to convert output from LASSO regresson to csv file.
First, I try to convert matrix to data.frame:
lasso_model = glmnet(x,y,alpha=1,lambda=c(0.0000000001,0.000000001,0.00000001,0.0000001,0.000001,0.00001,0.0001,0.001,0.01,0.1,1))
a<-coef(lasso_model)
class(a)
as.data.frame(t(a))
Then, there appears this problem:
Error in as.data.frame.default(a) :
cannot coerce class ‘structure("dgCMatrix", package = "Matrix")’ to a data.frame
However, when running your code, the error I get is Error in t.default(a) : argument is not a matrix so this example is not reproducible, there might be another problem.