Re: [R] dataframe indexing by number of cases per group

2011-11-24 Thread Johannes Radinger
t; Datum: Thu, 24 Nov 2011 09:12:57 -0500 > Von: Gabor Grothendieck > An: Johannes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] dataframe indexing by number of cases per group > On Thu, Nov 24, 2011 at 7:02 AM, Johannes Radinger > wrote: > > Hello, > > &g

Re: [R] dataframe indexing by number of cases per group

2011-11-24 Thread Gabor Grothendieck
On Thu, Nov 24, 2011 at 7:02 AM, Johannes Radinger wrote: > Hello, > > assume we have following dataframe: > > group <-c(rep("A",5),rep("B",6),rep("C",4)) > x <- c(runif(5,1,5),runif(6,1,10),runif(4,2,15)) > df <- data.frame(group,x) > > Now I want to select all cases (rows) for those groups > whi

Re: [R] dataframe indexing by number of cases per group

2011-11-24 Thread Dennis Murphy
A very similar question was asked a couple of days ago - see the thread titled "Removing rows in dataframe w'o duplicated values" - in particular, the responses by Dimitris Rizopoulos and David Winsemius. The adaptation to this problem is df[ave(as.numeric(df$group), as.numeric(df$group), FUN = le

[R] dataframe indexing by number of cases per group

2011-11-24 Thread Johannes Radinger
Hello, assume we have following dataframe: group <-c(rep("A",5),rep("B",6),rep("C",4)) x <- c(runif(5,1,5),runif(6,1,10),runif(4,2,15)) df <- data.frame(group,x) Now I want to select all cases (rows) for those groups which have more or equal 5 cases (so I want to select all cases of group A and