本文介绍了访问变量值,其中变量的名称存储在字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

针对其他语言提出了类似的问题:Csqljava

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"

如何通过在 x 上调用一些函数/操作来获得 (1, 2, 3),而不直接提到 ret_series?

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

这篇关于访问变量值,其中变量的名称存储在字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:53
查看更多