Re: [R] Split a list

2011-10-14 Thread Dennis Murphy
Hi: Following the lead of others, here's a reproducible example that I believe achieves what you want. # Q1: L <- lapply(1:3, function(n) data.frame(x = rnorm(6), y = rnorm(6), g = rep(1:2, each = 3))) # Using David's suggestion: L1 <- lapply(L, function(d) subset(d, g == 1L)) L2 <- lapply(L

Re: [R] Split a list

2011-10-14 Thread David Winsemius
On Oct 14, 2011, at 9:26 AM, Weidong Gu wrote: It would be nice if you could provide a sample. That is certainly true. However, if the data in the list have the same colnames, you can combine them by df<-do.call('rbind',your_list_data_frame) Then you can do what you want on the dataframe

Re: [R] Split a list

2011-10-14 Thread R. Michael Weylandt
Comments inline: On Fri, Oct 14, 2011 at 9:06 AM, Juliet Ndukum wrote: > I have a list of dataframes i.e. each list element is a dataframe with three > columns and differing number of rows. The third column takes on only two > values. I wish to split the list into two sublists based on the valu

Re: [R] Split a list

2011-10-14 Thread Weidong Gu
It would be nice if you could provide a sample. However, if the data in the list have the same colnames, you can combine them by df<-do.call('rbind',your_list_data_frame) Then you can do what you want on the dataframe instead of a list HTH Weidong Gu On Fri, Oct 14, 2011 at 9:06 AM, Juliet Nd

[R] Split a list

2011-10-14 Thread Juliet Ndukum
I have a list of dataframes i.e. each list element is a dataframe with three columns and differing number of rows. The third column takes on only two values. I wish to split the list into two sublists based on the value of the third column of the list element.  Second issue with lists as well. I