R-for循环-如何在变量名末尾增加数字

时间:2019-10-13 12:43:31

标签: r for-loop correlation

我正在使用R。我是初学者! 我只想在变量末尾增加数字,然后将此变量用于操作。

它应该只经过变量f1,f2,f3,f5 ...

此代码无效:

for (i in 1:45) {

          e1  <- paste("f",i,sep="")

         assign(e1,with(motivnew,eval(parse(text=e1))))

         cor.test(e1, motivnew$a_dauer, method="kendall") #the operation
       }

我从调查表中获得了一组数据。 f1-45包含大约100个人的答案(1-4)。我的目标是查看每个问题f1-f45与另一个变量的相关性。

0 个答案:

没有答案