[R] Process dataframes from list
Gábor Csárdi
csardi.gabor at gmail.com
Sun Oct 26 21:18:35 CET 2008
Wade, from your description it is not clear to me whether you have
fifty _R objects_ or fifty files containing tables (i.e. data frames).
If the former, you can do something like
a <- data.frame(1:10)
b <- data.frame(10:1)
c <- data.frame(letters[1:20])
my.data.frames <- data.frame( name=c("a", "b", "c") )
all.data <- lapply(as.character(my.data.frames$name), get)
and then all.data contains all your data frames, you can use a loop or
'lapply' to manipulate them.
If the data frames are in the file, then you can do something like this:
all.data <- lapply(as.character(my.data.frames$name), read.table, header=TRUE)
Other options to read.table can be added after 'header=TRUE'.
Is this something you wanted?
Best,
Gabor
On Sun, Oct 26, 2008 at 9:10 PM, Wade Wall <wade.wall at gmail.com> wrote:
> Hi all,
>
> I have roughly fifty dataframes and a dataframe with the names of the fifty
> dataframes. I want to perform the same set of manipulations on all fifty
> dataframes, but can't find a way to batch process from a list with the
> dataframe names using a loop. Is there a way to read the file names from
> the dataframe with the names and then call the referenced dataframe? This
> would save me a lot of typing.
>
> Thanks for any help,
>
> Wade
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
--
Gabor Csardi <Gabor.Csardi at unil.ch> UNIL DGM
More information about the R-help
mailing list