One alternative that I use is illustrated in the following examples:

> DF[DF$x==DF$y, ]
  x  y z
1 -1 -1 a
4  1  1 d
>
> sel <- (DF$x != DF$y)
> DF[sel,]
  x  y z
2  1 -1 b
3 -1  1 c

hope this help. spencer graves

Douglas Bates wrote:

"subset" will do the selection.  If you really want a matrix for the
result you will need to coerce it using "as.matrix".

Roger Levy <[EMAIL PROTECTED]> writes:



I have a simple question about matrix/data frame manipulation.  I have
a data frame that looks a something like this

 X    Y    Z
 1    0    "apples"
 -1   -1   "oranges"
 ...
 0    -1   "bananas"

and I'd like to pull out all the rows for which X and Y are (un)equal
into a submatrix.

How can I do that?

Many thanks,

Roger Levy



______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to