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, 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.? Thank You, Mike Smith
On Mon, 2011-05-02 at 16:42 -0700, 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, 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.My understanding is that you want to have one data frame per week. I question whether it is necessary to split these data frames. I would design a single data frame with one column to identify the week and then work on subsets of that data frame to calculate the weekly stats or cumulative indexes as you wish. Jerome
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