我想知道如何将完整循环输出的值存储到 R 中的单个数据帧中。例如,
for(i in unique(x$id)){
.
.
.
y=output of one iteration}
在每次迭代结束时,我都会在 y 中获得输出。但我想将所有迭代的输出存储到 y 中。我如何在 R 中做到这一点?
最佳答案
你可以简单地做到这一点
y <- NULL;
for (i in unique(x$id))
{
tmp <- [output of one iteration]
y <- rbind(y, tmp)
}
关于r - 将循环输出存储在 R 中的数据帧中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31862933/