Using table() not the best, because then you have to connect to the source lines of data.frame. The ave function makes it easy to calculate line level values ββfor different groups. for example
dd<-data.frame( a=1:10, b=c(1,1,2,3,4,4,4,5,6, 6) ) dd[with(dd, ave(b,b,FUN=length))>1, ] #subset(dd, ave(b,b,FUN=length)>1) #same thing ab 1 1 1 2 2 1 5 5 4 6 6 4 7 7 4 9 9 6 10 10 6
Here for each level b it calculates the length b , which is actually just the number b and returns this back to the corresponding line for each value. Then we use this subset.
MrFlick Jul 01 '14 at 6:08 2014-07-01 06:08
source share