我将创建一个创建模型的循环。具有最高值的模型应该稍后使用,
d <- data.frame()
for(i in 1:100){
model <- lm(...)
d <- rbind(d,model_result)
# here the results should be saved
# if the model_result is higher than the highest before (in data frame "d") it
should be saved, so that i can use it later.
ifelse(model_result > max(d$V1), saveRDS(model,file = "mymodel.rds"), "")
}
model <- readRDS("mymodel.rds")
保存工作,但不仅仅保存最高值而不是每个值,所以savest的模型总是最新的循环而不是最高。
我仍然尝试过其他if-else功能,但没有人工作。
答案 0 :(得分:0)
出于上述目的,请使用if()
而不是ifelse()