On Sun, Feb 10, 2013 at 5:31 AM, catalin roibu <catalinro...@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

______________________________________________
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.

Reply via email to