access parametrically values of variables inside environments
- by Apostolos
Let's say we have one or more environments and variables in them.
My question is how we access the values of these variables, parametrically.
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
Thank you all, in advance