Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Ragia Ibrahim
lots of thanksĀ  Ragia > Date: Wed, 2 Dec 2015 14:12:46 -0800 > Subject: Re: [R] extract rows based on column value in a data frame > From: bgunter.4...@gmail.com > To: dwinsem...@comcast.net > CC: ragi...@hotmail.com; r-help@r-project.org &g

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Bert Gunter
... Perhaps also worth mentioning -- David's solution works even if there are less than 3 rows per group, whereas mine will fail. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Wed, Dec 2, 2015 a

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Bert Gunter
... or perhaps using rep() to do the indexing directly instead of matching: dfrm[ ave(dfrm$v1, dfrm$v1, FUN = function(x)rep(c(TRUE,FALSE),c(3,length(x)-3))), ] There's probably another 6 dozen ways to do it, especially if you access packages like data.table, plyr, etc. Cheers, Bert Bert Gunte

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread David Winsemius
> On Dec 2, 2015, at 10:09 AM, Ragia Ibrahim wrote: > > Dear Group, > I have a data frame that such as > > v1 v2v3v4 > 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