From murdoch@stats.uwo.ca  Thu Oct  4 14:40:04 2001
From: murdoch@stats.uwo.ca (Duncan Murdoch)
Date: Thu, 04 Oct 2001 09:40:04 -0400
Subject: [Rd] Re: [R] Several R vs S-Plus issues
In-Reply-To: <15292.6722.281945.237767@mithrandir.hornik.net>
References: <200110032059.f93KxLo19424@arbres1a.FMR.Com> <15292.6722.281945.237767@mithrandir.hornik.net>
Message-ID: <j3portg76ce4qiqk00cavm0mgq9i8lukja@4ax.com>

On Thu, 4 Oct 2001 10:13:54 +0200, you wrote in message
<15292.6722.281945.237767@mithrandir.hornik.net>:
>  Note that in R,
>
>R> is.na(LETTERS[c(NA,2)])
>[1]  TRUE FALSE
>
>so we really have NA but it is printed as "NA" (and this might be
>another case where <NA> would be better).

I think NA and "NA" are treated in a very confusing way in R.  In y
below, I construct an NA the way you did above; in z, I use the string
'NA'.  As far as I can tell the vectors are identical.  In w, I use
paste(NA), and get something different.  I also tried paste('NA'), and
get something that looks like w.

 > x <- 'a'
 > y <- x[c(1,NA)]
 > y
 [1] "a"  "NA"
 > y == 'NA'
 [1] FALSE  TRUE
 > is.na(y)
 [1] FALSE  TRUE

 > z <- c('a', 'NA')
 > z == 'NA'
 [1] FALSE  TRUE
 > is.na(z)
 [1] FALSE  TRUE
 > y == z
 [1] TRUE TRUE

 > w <- c('a',paste(NA))
 > w == 'NA'
 [1] FALSE  TRUE
 > is.na(w)
 [1] FALSE FALSE         # This is a surprising result!
 > y == w
 [1] TRUE TRUE

Duncan

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


[Rd] Re: [R] Several R vs S-Plus issues
Duncan Murdoch