> On Dec 2, 2015, at 10:09 AM, Ragia Ibrahim <ragi...@hotmail.com> wrote: > > Dear Group, > I have a data frame that such as > > v1 v2 v3 v4 > 1 1 3 6 > 1 1 5 6 > 1 1 8 0 > 1 2 6 1 > 1 2 4 0 > 1 3 4 4 > 1 3 5 4 > 1 3 6 3 > 1 3 7 1 > > 2 4 3 7 > 2 5 5 4 > 2 5 8 2 > 2 1 6 1 > 2 1 4 0 > 2 1 4 3 > 2 1 5 2 > 3 1 6 1 > 3 6 7 0 > > 3 6 3 6 > 3 6 5 6 > 3 6 8 0 > 3 6 6 1 > 3 2 4 0 > 3 2 4 4 > 3 2 5 4 > 3 2 6 3 > 3 2 7 1 > 3 5 9 5 > 3 6 9 5 > > > the result required is each first 3 rows, from distinct v2 column for each > v1 column > > > v1 v2 v3 v4 > 1 1 3 6 > 1 2 6 1 > 1 3 4 4 > 2 4 3 7 > 2 5 5 4 > 2 1 6 1 > 3 6 3 6 > 3 2 4 0 > 3 5 9 5
Probably something along the lines of dfrm[ ave(dfrm$v1, dfrm$v1, FUN=seq_along) %in% 1:3 , ] > > > thanks in advance > [[alternative HTML version deleted]] Future postings should be in plain text. — David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.