From tlumley@u.washington.edu  Tue Aug 27 05:02:56 2002
From: tlumley@u.washington.edu (Thomas Lumley)
Date: Mon, 26 Aug 2002 21:02:56 -0700 (PDT)
Subject: strange result from x[x!="NA"] (PR#1952)
In-Reply-To: <200208270021.CAA09251@pubhealth.ku.dk>
Message-ID: <Pine.A41.4.44.0208262057200.11546-100000@homer20.u.washington.edu>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


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