我收到以下错误
Error in storage.mode(y) <- "double" : invalid to change the storage mode of
a factor
正确设置输入矩阵格式的问题。 这里的代码:
library("glmnet")
daten = read.csv("test.csv",header = 1)
# Sex Age Weight Height Other
# 0 22 54 154 1.51
# 1 34 76 178 1.94
# 1 38 75 178 1.93
# 1 32 102 178 2.19
# ...
# 1 35 94 184 2.18
trainX <- daten
# outcome variable
Y <- c(0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,1)
trainY <- factor(Y)
fit.lasso=glmnet(trainX,trainY,alpha=1)
trainY的格式似乎正确,但是trainX怎么了?
任何评论将不胜感激。