From ripley@stats.ox.ac.uk  Sat May 11 10:51:02 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Sat, 11 May 2002 10:51:02 +0100 (BST)
Subject: [Rd] vector(NA, 3) (PR#1541)
In-Reply-To: <200205110628.IAA29669@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.31.0205111045550.26771-100000@gannet.stats>

On Sat, 11 May 2002 ripley@stats.ox.ac.uk wrote:

> On Sat, 11 May 2002 pgilbert@bank-banque-canada.ca wrote:
>
> > I don't seem to be able to initialize a vector of NAs. I hope this is a
> > bug and not a new feature (I realize I have not paid much attention to a
> > lot of recent discussion about NA):
>
> It's an incorrect use!
>
> From the help page:
>
>     mode: A character string giving an atomic mode, or `"any"'.
>
> I think you meant rep(NA, 3).

To amplify that, rep(NA, 3) gives a vector of *logical* NAs, just as
matrix(NA, 2, 2) gives a logical matrix.   There are five different
missing values in R, and `NA' happens to be mapped to the logical one
(unless coerced, implicitly or explicitly).

People normally want numerical missing values, for which use
rep(as.numeric(NA), 3).  Replace `numeric' by `integer', `complex' or
`character' for the other possibilities.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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] vector(NA, 3) (PR#1541)
ripley@stats.ox.ac.uk