如何动态命名变量? [英] How to name variables on the fly?
本文介绍了如何动态命名变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以即时创建新的变量名?
Is it possible to create new variable names on the fly?
我想将列表中的数据帧读入新变量,并在末尾加上数字.像orca1,orca2,orca3 ...
I'd like to read data frames from a list into new variables with numbers at the end. Something like orca1, orca2, orca3...
如果我尝试类似的事情
paste("orca",i,sep="")=list_name[[i]]
我收到此错误
target of assignment expands to non-language object
还有其他解决方法吗?
推荐答案
使用assign
:
assign(paste("orca", i, sep = ""), list_name[[i]])
这篇关于如何动态命名变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文