[R] Logical statements and subseting data...

Neil Shephard nshephard at gmail.com
Mon Feb 25 15:36:13 CET 2008


Thanks Thierry, they do both leave me with what I expected.

On Mon, Feb 25, 2008 at 2:28 PM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> The negation of Height.1 == 0 & Height.2 == 0 was incorrect. Use
>
>  subset(raw.all.clean, !(Height.1 == 0 & Height.2 == 0))

I can see clearly how this expression works (negating the whole test), but...

>  or
>
>  subset(raw.all.clean, Height.1 != 0 | Height.2 != 0)

...not how this works, since the above to me is saying Height.1 is NOT
zero OR  Height.2 is NOT zero, which to my mind would pick out samples
where either one or the other is not equal to zero (and of course
those instances where both are equal to zero)?

It seems to me that & (AND) and | (OR) are used the wrong way round in
this case, since the intersection of the two tests for inequality is
what is required?

Neil
-- 
Email - nshephard at gmail.com / n.shephard at sheffield.ac.uk



More information about the R-help mailing list