It's not. Look at the value of y > 0: It's c(F, F, T, NA). Indexing y by
this gives you c(1, NA). If you don't know the value of y[4], you don't
know whether it's greater than 0 or not, so it makes sense to have NA in y[y
> 0].
If you do not want NAs, exclude them by something like y[!is.na(y) & y > 0].
Andy
> Eva Goldwater
>
> I am puzzled by the fact that NA apparently test true for any logical
> condition. For example:
>
> > y <- c(-1,0,1,NA)
> > y[y>0]
> [1] 1 NA
> > y[y<=0]
> [1] -1 0 NA
>
> I would have expected that NA should fail all logical tests.
> Can anyone
> explain this weird behaviour? Is there an option that
> controls it, or do I
> always have to eliminate NAs manually?
>
> I am using S-Plus 6.2 on Windows. Thank you,
>
> Eva Goldwater email:
> goldwater@schoolph.umass.edu
> Biostatistics Consulting Phone: (413) 545-2949
> 418 Arnold House Fax: (413) 545-1645
> 715 North Pleasant Street
> University of Massachusetts
> Amherst, MA 01003-9304
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
>
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
Jersey, USA 08889), and/or its affiliates (which may be known outside the
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
Banyu) that may be confidential, proprietary copyrighted and/or legally
privileged. It is intended solely for the use of the individual or entity named
on this message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and then delete
it from your system.
------------------------------------------------------------------------------
|