[R] Process dataframes from list

Gábor Csárdi csardi.gabor at gmail.com
Mon Oct 27 14:30:44 CET 2008

On Mon, Oct 27, 2008 at 2:24 PM, Wade Wall <wade.wall at gmail.com> wrote:
> Hi Gabor,
> Thanks for the code, it's what I was looking for.  The route I was
> thinking about was to use, based on your code, the names from
> my.data.frames as a pointer to the actually dataframes.
> I was envisioning something like
> a <- data.frame(1:10)
> b <- data.frame(10:1)
> c <- data.frame(letters[1:20])
> my.data.frames <- c("a", "b", "c")
> for (i in length(my.data.frames)) {
>   function(my.data.frames[[i]]*, arguments)
>   }
>     with my.data.frame[[i]]* acting as a pointer to the actual data.frame.
> Is it possible to create pointers from a list of data frame names to
> the actual data frames?

I think it was in my previous email, but then again, use "get" to put
them in a list:

all.data <- lapply(my.data.frames, get)

and then you can handle them easily, e.g. your example would be something like

lapply(all.data, function, arguments)

It is not necessary to put them in a list, but I think it is cleaner
than using "get" all the time.


> Thanks for the help.
> Wade

Gabor Csardi <Gabor.Csardi at unil.ch>     UNIL DGM

More information about the R-help mailing list