Does anyone knows why this is producing an error like this (Error in { :
task 1 failed - "arguments imply differing number of rows: 1, 0")?
I tried to run a loop through large data to predict one unique row from the dataset using ranger package. Is the problem because rows don't have a similar length or something else?
Thanks
library(ranger)
name = as.vector(unique(my_data$ID))
pa = my_data[-(which(names(my_data)=="ID"))]
test1=NULL
pre= NULL
foreach(p = 1:length(name), combine = "rbind") %dopar% {
train = subset(pa, my_data$ID != p)
test = subset(pa, my_data$ID == p)
rf.fit = ranger(rain ~.,data=train, num.trees=500, importance = "permutation", write.forest = TRUE)
rf.pred = predict(rf.fit,test)
test1= rbind(test1,test)
pre = c(pre,rf.pred$predictions)
cat(p,"\n")
}