POSIX formats have problems with NA (PR#1732)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Wed, 3 Jul 2002 15:28:41 +0100 (BST)


On Wed, 3 Jul 2002, Jens [ISO-8859-1] Oehlschlägel wrote:

>
> Brian,
>
> Thanks for answering.
>
> > This feature request is already implemented in R-devel.
>
> good to know that it is done in R-devel
>
> > It is not a bug, as why should logical NA be convertible to any other
> > format?
>
> Why then do we have as.character(NA)?

We also have as.character(T) and as.character(F): it's coercion of logicla
vectors which is implemented.

> Isn't it standard, that a as.something() function can handle NAs? Isn't it
> good style to explicitely use as.something(NA) instead of relying on
> auto-coercion? Isn't it a language feature that we can assign NA to any element of a
> vector, especially if NA is a legal (creatable) element?

A POSIXct class (say) is not a vector, strictly. The problem is that `NA'
is a _logical_ vector, and although one can reasonably coerce NA, one
cannot coerce T and F.  So it needs special-case code, and I don't think
you will find it documented anywhere that this needs to work.

Brian

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