Re: [R] subsetting matrix according to columns with character index

2008-08-13 Thread markleeds
didn't get Henriques message in my mailbox immediately for some reason - -Ralph ___ Date: Wed, 13 Aug 2008 14:23:33 -0500 From: [EMAIL PROTECTED] Subject: RE: [R] subsetting matrix according to columns with character index To: [EMAIL PROTECTED] CC: r-help@r-pr

Re: [R] subsetting matrix according to columns with character index

2008-08-13 Thread markleeds
t; Subject: RE: [R] subsetting matrix according to columns with character > index To: [EMAIL PROTECTED] > it must be a dataframe so, if it was DF, then, assuming i understand > what you want then either of the following should work: > DFsub<-DF[DF$z == 1 & DF$z == 2,] > or >

Re: [R] subsetting matrix according to columns with character index

2008-08-13 Thread markleeds
a what to do? -Ralph > Date: Wed, 13 Aug 2008 13:05:25 -0500 From: [EMAIL PROTECTED] > Subject: RE: [R] subsetting matrix according to columns with character > index To: [EMAIL PROTECTED] > it must be a dataframe so, if it was DF, then, assuming i understand > what you want then

Re: [R] subsetting matrix according to columns with character index

2008-08-13 Thread Ralph S.
n a and c combination. Any idea what to do? -Ralph > Date: Wed, 13 Aug 2008 13:05:25 -0500 > From: [EMAIL PROTECTED] > Subject: RE: [R] subsetting matrix according to columns with character index > To: [EMAIL PROTECTED] > > it must be a dataframe so, if it was DF, then, assuming i

Re: [R] subsetting matrix according to columns with character index

2008-08-13 Thread Henrique Dallazuanna
Try this: x V1 V2 V3 1 a1 c1 1 2 a1 c1 2 3 a2 c1 1 4 a1 c2 1 5 a1 c2 2 lis <- split(x, list(x$V1, x$V2), drop = TRUE) do.call(rbind, unname(lis[sapply(lis, function(x)all(1:2 %in% x[,3]))])) On Wed, Aug 13, 2008 at 3:00 PM, Ralph S. <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a long m

[R] subsetting matrix according to columns with character index

2008-08-13 Thread Ralph S.
Hi, I have a long matrix of the following form which I would like to subset according to the third column: [x y z]: a1 c1 1 a1 c1 2 a2 c1 1 a1 c2 1 a1 c2 2 . . . The first two columns a characters ai and cj. I would like to keep all the rows where there are two entries for z, 1 and 2. Tha