Skip to content
Prev 244512 / 398506 Next

Delete observations with a frequency < x

Suppose this is your data frame:
x y
1 1 a
2 1 b
3 1 c
4 2 a
5 2 b
6 2 d
x y
1 1 a
2 1 b
4 2 a
5 2 b

Note that this will only work properly if y is a factor or character
variable.  If y was numeric, you would need

df[!table(df$y)[as.character(df$y)]

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Thu, 9 Dec 2010, mathijsdevaan wrote: