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.

Reply via email to