[R] problem selecting rows meeting a criterion
Jim Bouldin
jrbouldin at ucdavis.edu
Tue Aug 11 23:15:57 CEST 2009
Yes, thanks Steve and also to everyone else for helping me clear this up.
The issue was definitely the existence of other objects named X and Y that
I inadvertently referred to in my command statement. Only when these
objects are removed AND the data frame in question is attached, will the
command I originally used work. However, I see that it is much easier to
just use the subset function or perhaps the with function. Seems that R has
many painful lessons to teach. Thanks again.
Jim Bouldin
> This won't work in general, and is probably only working in this
> particular case because you already have defined somewhere in your
> workspace vars named X and Y.
>
> What you wrote above isn't taking the values X,Y from data$X and data
> $Y, respectively, but rather from var X and Y defined elsewhere.
>
> Instead of doing data[X > Y], do:
>
> data[data$X > data$Y,]
>
> This should get you what you're expecting.
...
>
> Hopefully you're learning a slightly different lesson now :-)
>
> Does that clear things up at all?
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
> | Memorial Sloan-Kettering Cancer Center
> | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
>
More information about the R-help
mailing list