[R] top 10 (n values) for each classes
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Feb 10 20:32:05 CET 2013
On Sun, Feb 10, 2013 at 5:31 AM, catalin roibu <catalinroibu at gmail.com> wrote:
> Dear R users,
> I have a problem. I don't know how to select the top 10 (n) values for each
> classes.
Assuming that by top n values in each group you mean the first n rows
in each group then:
n <- 5
dat1[ave(dat1$cls, dat1$cls, FUN = seq_along) <= n, ]
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list