Try this: subset(x, ave(x$ID, x$Pol., FUN = length) >= 3)
On Wed, Jun 1, 2011 at 8:00 PM, kristina p <puzarin...@gmail.com> wrote: > Dear R Team, > > I am a new R user and I am currently trying to subset my data under a > special condition. I have went through several pages of the subsetting > section here on the forum, but I was not able to find an answer. > > My data is as follows: > > ID NAME MS Pol. Party > 1 John x F > 2 Mary s S > 3 Katie x O > 4 Sarah p L > 5 Martin x O > 6 Angelika x F > 7 Smith x O > .... > > I am intested in only those observations, where there are at least three > members of 1 political party. That is, I need to throw out all cases in the > example above, except for members of party "O". > > Would really appreciate your help. > K > > -- > View this message in context: > http://r.789695.n4.nabble.com/subsetting-with-condition-tp3567193p3567193.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.