我正在运行代码以适应LASSO分析,但是当我运行代码时,我收到以下错误:Error in sort.list(y) : 'x' must be atomic for 'sort.list'
。有人可以更清楚地解决这个问题吗?
library(caret)
set.seed(3523)
library(AppliedPredictiveModeling)
data(concrete)
inTrain = createDataPartition(concrete$CompressiveStrength, p = 3/4)[[1]]
training = concrete[ inTrain,]
testing = concrete[-inTrain,]
library(lars)
lasso <- lars(x=as.matrix(as.factor(training),
y=concrete$CompressiveStrength, type="lasso", trace=FALSE,
normalize = TRUE))
答案 0 :(得分:2)
我猜您代码中的最后一个命令应如下所示:
lasso <- lars(x=as.matrix(training), y=training$CompressiveStrength, type="lasso", trace=FALSE,normalize = TRUE)