Re: [R] subset dataframe by number of rows of equal values

2009-05-24 Thread jim holtman
Here is one way of doing it: > moreThan <- ave(choose$code, choose$code, FUN=length) > moreThan [1] 2 2 4 4 4 4 2 2 6 6 6 6 6 6 > choose[moreThan > 2,] firm year code 3 2 2000 11 4 2 2001 11 5 2 2002 11 6 2 2003 11 9 4 2001 13 104 2002 13 114 2003 13 1

[R] subset dataframe by number of rows of equal values

2009-05-24 Thread Cecilia Carmo
Hi R helpers! I have the following dataframe «choose» choose<-data.frame(firm=c(1,1,2,2,2,2,3,3,4,4,4,4,4,4), year=c(2000,2001,2000,2001,2002,2003,2000,2003,2001,2002,2003,2004,2005,2006),code=c(10,10,11,11,11,11,12,12,13,13,13,13,13,13)) choose I want to subset it to obtain another one with t