
  i don't think i understood what you were trying to do, atleast based 
on Henrique's solution which I haven't cut and pasted yet in order
to understand. Did Henrique's solution do what you wanted ?

On Wed, Aug 13, 2008 at  2:45 PM, Ralph S. wrote:

I tried this - I get an empty set:

<0 rows> (or 0-length row.names)

I guess this happens because the z variable takes only one value per 
row??

What works is:
DFsub<-DF[DF$z == 1 | DF$z == 2,]

but then, I do not eliminate the entries where there is only one entry 
for z given an a and c combination.

Any idea what to do?

-Ralph

> Date: Wed, 13 Aug 2008 13:05:25 -0500 From: markleeds@verizon.net 
> Subject: RE: [R] subsetting matrix according to columns with character 
> index To: ruffel1@hotmail.com
>   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
> DFsub<-subset(DF, z == 1 & z == 2 )
>
> On Wed, Aug 13, 2008 at  2:00 PM, Ralph S. wrote:
>> 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.
>> That is, I want: a1 c1 1 a1 c1 2 a1 c2 1 a1 c2 2 . . .
>> I try to use something like df[by(df,c(df$x,df$y),sum(z)==3),] but 
>> that only gives me one line of data per x y combination.
>> Is there an easy way of coding to keep all rows for a and c 
>> combinations where z has entries both 1 and 2? Many thanks,
>> Ralph
>> _________________________________________________________________
>>
>> LM_WLYIA_whichathlete_us 
>> ______________________________________________ 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.

___________________________________

Your PC, mobile phone, and online services work together like never 
before. See how Windows® fits your life 
<http://clk.atdmt.com/MRT/go/108587394/direct/01/>

	[[alternative HTML version deleted]]

