Re: [R] Loading a list into the environment

2013-02-04 Thread Greg Snow
An often better approach is to use a function like with or within. These allow you to run a command with your list (data frame, environment, etc.) in the first position of the search list so they behave like they are in the global environment (actually better because they temporarily mask rather t

Re: [R] Loading a list into the environment

2013-02-02 Thread Jonathan Greenberg
Thanks all! list2env was exactly what I was looking for. As an FYI (and please correct me if I'm wrong), if you want to load a list into the current environment, use: myvariables <- list(a=1:10,b=20) loadenv <- list2env(myvariables ,envir=environment()) a b --j On Fri, Feb 1, 2013 at 5:49 PM,

Re: [R] Loading a list into the environment

2013-02-01 Thread Rui Barradas
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 Gr

Re: [R] Loading a list into the environment

2013-02-01 Thread Gabor Grothendieck
On Fri, Feb 1, 2013 at 5:24 PM, Jonathan Greenberg wrote: > 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 myvar