假设我们有一个或多个环境和变量。我的问题是我们如何以参数方式访问这些变量的值。
rm(list = ls())
env1 <- new.env()
env1$var1 <- "value1"
env2 <- new.env()
env2$var2 <- "value2"
env <- ls.str(mode="environment") # We get the environments
var <- ls.str(eval(parse(text = env[1])))# We get the variables of an environment
eval(var[1]) # We fail to get the value of a variable
get(var[1], envir=env[1]) # It does not work, either
谢谢大家