简体   繁体   English

循环遍历R中的数字列表

[英]Looping through number list in R

I'm trying to loop through a list of numbers and concatenate them at the end of a variable. 我试图遍历一个数字列表并在变量的末尾连接它们。

for(i in c(3,6,9)) {
    x3=...
    x6=...
    x9=...  }

Is there a way to macro numbers using R such as something like x`i'? 有没有一种方法可以使用R来表示像x`i'这样的东西?

It is possible but not recommended : 有可能但不推荐

for(i in c(3,6,9))
 assign(paste("a",i,sep=""),value=...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM