[R] simple question on picking out some rows of a matrix/data frame

Hadley Wickham h.wickham at auckland.ac.nz
Tue Feb 10 00:26:35 CET 2004


Have you looked at subset?
eg subset(dataframe, x != y, select = c(x, y))

Hadley

Roger Levy wrote:
> Hi,
> 
> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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




More information about the R-help mailing list