Re: [R] List of Data Frames

From: Rolf Turner <rolf.turner_at_xtra.co.nz>
Date: Tue, 03 May 2011 13:00:44 +1200

On 03/05/11 11:42, Mike Smith wrote:
> I'm trying to create a list of Data Frames. I have 17 data frames that I need to move through in a loop, but if I simply make a list of them, then they do not stay data frames,

     That is simply not true. Just ***how*** did you ``make a list of them''???
> and I can't sort through them. I tried to create an array, but the data frames can have anywhere from 14-16 rows, and I couldn't find a way to make a variable size array. If you have any ideas, I would greatly appreciate any help, as I'm trying to learn R, and decided to apply it to a project that I have been working on. My goal is splitting a sports season into games per week, and then do statistics on each week, but have an average running up to that point in the season. Thus the list would be indexed by weeks, and then there's a data frame of the game and all relevant statistics.

You can make a list of data frames with syntax something like

     L <- list(DF1, DF2,etc.)

where DF1, ... DF17 are your data frames.

If your data frames all have the same number of columns (and the column names are the same) you might want to rbind() them together into a single data frame. If the data frames correspond to ``week'' then you might want to add a ``week'' column to each data frame before doing the rbind(); the value of week would be constant over the rows of each of your original data frames, but would of course vary over rows in your ``big'' data frame (the object returned by rbind).

It's very hard to recommend anything specific, since your question was so vague. I suggest that you read the Posting Guide.

         cheers,

                 Rolf Turner

______________________________________________
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. Received on Thu 05 May 2011 - 06:25:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive