访问变量值,其中变量名称存储在字符串中 [英] Access variable value where the name of variable is stored in a string
本文介绍了访问变量值,其中变量名称存储在字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于其他语言也提出了类似的问题: C , sql , java 等.
Similar questions have been raised for other languages: C, sql, java, etc.
但是我正在尝试在R中执行此操作.
But I'm trying to do this in R.
我有:
ret_series <- c(1, 2, 3)
x <- "ret_series"
如何在不直接提及ret_series
的情况下通过调用x
上的某些函数/操作来获得(1, 2, 3)
?
How do I get (1, 2, 3)
by calling some function / manipulation on x
, without direct mentioning of ret_series
?
推荐答案
您提供了问题的答案.尝试get
.
You provided the answer in your question. Try get
.
> get(x)
[1] 1 2 3
这篇关于访问变量值,其中变量名称存储在字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文