Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
R编程问题:
我有一个关于如何将字符向量转换为变量名向量(已分配给数字)的问题。
这是一个简单的例子。
假设我定义了以下变量:
a=1;b=2;
现在,如果我输入
x=c(a,a,b) 我将 x 设置为向量 1,1,2
现在假设我有一个由字符组成的向量:
y=c('a','a','b')
如何将向量 y 中的字符转换为我已经定义的变量?即我能做什么,以便我可以将字符向量 'a','a','b' 转换为向量 1,1,2(因为我设置了 a=1 和 b=2)?
提前致谢!