且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将for循环的结果存储在唯一对象中

更新时间:2022-12-26 21:47:48

You can specify your store variable beforhand without determine how many values it shall store. If you want for each value a seperate variable take a look at the paste function.

x<- NULL
for (i in 1:10){
x[i] <- i*2
}

*edit: The comment above is right. This way is not the most efficent one. But I still use it when computation time is not an issue.

相关阅读

技术问答最新文章