sort.list(y)出错:'x'必须是'sort.list'的原子

时间:2015-10-31 16:04:29

标签: r performance sorting r-caret

我正在运行代码以适应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))

1 个答案:

答案 0 :(得分:2)

我猜您代码中的最后一个命令应如下所示:

lasso <- lars(x=as.matrix(training), y=training$CompressiveStrength,     type="lasso", trace=FALSE,normalize = TRUE)