Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
Ted, Based upon your code below, you might be better off using two lapply() constructs to create the x and y results separately, taking advantage of lapply()'s built-in ability to create lists 'on the fly', while returning a NULL when the function will not be applied to the data based upon your

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
Thanks Marc Part of the challenge here is that EVERYTHING is dynamic. New data is being added to the DB all the time Each active ID makes a new sample very day or at a minimum every week, and new IDs are added every week. So I can't hard code anything. If, for a given ID, I had 50 weekly sampl

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
Ted, I may not be completely clear on how you have your processes implemented, but some thoughts: If you will be creating multiple lists initially, where each list (say z1...z4) contains 1 or more data frames and all of the data frames have the same column structure, you can use: do.call(rb

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
Thanks Marc The next part of the question, though, involves the fact that there is a new 'z' list made in almost every iteration through the ID loop. I guess there are two parts to the question. First, how would I make a list containing all the data frames created by a call to rbind? I assume,

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 2:18 PM, Ted Byers wrote: > The data.frame is constructed by one of the following functions: > > funweek <- function(df) > if (length(df$elapsed_time) > 5) { >rv = fitdist(df$elapsed_time,"exp") >rv$year = df$sale_year[1] >rv$sample = df$sale_week[1] >rv$granu

[R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
The data.frame is constructed by one of the following functions: funweek <- function(df) if (length(df$elapsed_time) > 5) { rv = fitdist(df$elapsed_time,"exp") rv$year = df$sale_year[1] rv$sample = df$sale_week[1] rv$granularity = "week" rv } funmonth <- function(df) if (