Hello, Something like this?
myfun <- function(x, envir = .GlobalEnv){ nm <- names(x) for(i in seq_along(nm)) assign(nm[i], x[[i]], envir) } myvariables <- list(a=1:10,b=20) myfun(myvariables) a b Hope this helps, Rui Barradas Em 01-02-2013 22:24, Jonathan Greenberg escreveu:
R-helpers: Say I have a list: myvariables <- list(a=1:10,b=20) Is there a way to load the list components into the environment as variables based on the component names? i.e. by applying this theoretical function to myvariables I would have the variables a and b loaded into the environment without having to explicitly define them. --j
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.