我有以下格式的小标题或嵌套数据帧(df):
为了对小标题执行随机森林,我使用了以下代码:
rfmodel=function(X,Y){
ctrl=trainControl(
method = "cv",
number = 3
)
train(x=X,y=Y,
trControl = ctrl,
method = 'rf')
}
#using rf model
set.seed(12345)
df=df%>%
#declaring new vars param and model to capture the model outputs
mutate(param=map2(train.x,train.y,~list(.x,.y)),
model=invoke_map(rfmodel,param))
执行后,出现以下错误:
Error in check_dims(x = x, y = y) : nrow(x) > 1 is not TRUE
In addition: There were 50 or more warnings (use warnings() to see the first 50)
我搜索了一些类似的错误,其中大多数是关于变量数据类型的,在这里是数字。
请就如何解决此错误提出建议。提前致谢。