strange result from x[x!="NA"] (PR#1952)

Thomas Lumley tlumley@u.washington.edu
Mon, 26 Aug 2002 21:02:56 -0700 (PDT)


On Tue, 27 Aug 2002 rsingle@zoo.uvm.edu wrote:

> Full_Name: Richard Single
> Version: 1.5.1
> OS: Windows
> Submission from: (NULL) (132.198.176.82)
>
>
> In the latest Windows version the following syntax behaves
> differently than it did in version 1.4.0: x[x!="NA"]
> The results under R 1.4.0 agree with S.

Yes.  It's a deliberate change in 1.5.0, documented in both the NEWS file
and the guide to updating to 1.5.  The string "NA" is not special any
more, you need as.character(NA) to make a missing string, and you need to
use is.na() to test for NAs, as was always recommended.


	-thomas


> --Rich
>
> R 1.4.0
> > x <- c(NA, 2, 3, NA)
> > x == "NA"
>  [1]  TRUE FALSE FALSE  TRUE
> > is.na(x)
>  [1]  TRUE FALSE FALSE  TRUE
>
>
> R 1.5.1
> > x <- c(NA, 2, 3, NA)
> > x == "NA"
>  [1]    NA FALSE FALSE    NA
> > is.na(x)
>  [1]  TRUE FALSE FALSE  TRUE
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

Thomas Lumley			Asst. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle
^^^^^^^^^^^^^^^^^^^^^^^^
- NOTE NEW EMAIL ADDRESS

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._