gpt4 book ai didi

r - 将循环输出存储在 R 中的数据帧中

转载 作者:行者123 更新时间:2023-12-03 22:50:38 24 4
gpt4 key购买 nike

我想知道如何将完整循环输出的值存储到 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com