This feature request is already implemented in R-devel.
It is not a bug, as why should logical NA be convertible to any other
format?
On Tue, 2 Jul 2002 oehl_list@gmx.de wrote:
>
> # pure replication code at end
>
> > # These work
> >
> > Sys.time() + NA
> [1] NA
> > as.POSIXlt(Sys.time(), "GMT") + NA
> [1] NA
> >
> > class(Sys.time() + NA)
> [1] "POSIXt" "POSIXct"
> > class(as.POSIXlt(Sys.time(), "GMT") + NA)
> [1] "POSIXt" "POSIXct"
> >
> > x <- Sys.time() + NA
> > y <- as.POSIXlt(Sys.time(), "GMT") + NA
> >
> > is.na(x)
> [1] TRUE
> > is.na(y)
> [1] TRUE
> >
> > x <- NA
> > class(x) <- c("POSIXt", "POSIXct")
> > is.na(x)
> [1] TRUE
> >
> > # but these fail
> >
> > is.na(x) <- TRUE
> Error in as.POSIXct.default(value) : Don't know how to convert
`value' to
> class "POSIXct"
> > is.na(y) <- TRUE
> Error in as.POSIXct.default(value) : Don't know how to convert
`value' to
> class "POSIXct"
> >
> > x[] <- NA
> Error in as.POSIXct.default(value) : Don't know how to convert
`value' to
> class "POSIXct"
> > y[] <- NA
> Error in as.POSIXct.default(value) : Don't know how to convert
`value' to
> class "POSIXct"
> >
> > as.POSIXlt(NA)
> Error in as.POSIXlt(NA) : Don't know how to convert `NA' to class
"POSIXlt"
> > as.POSIXct(NA)
> Error in as.POSIXct.default(NA) : Don't know how to convert `NA' to
class
> "POSIXct"
>
>
>
>
> # These work
>
> Sys.time() + NA
> as.POSIXlt(Sys.time(), "GMT") + NA
>
> class(Sys.time() + NA)
> class(as.POSIXlt(Sys.time(), "GMT") + NA)
>
> x <- Sys.time() + NA
> y <- as.POSIXlt(Sys.time(), "GMT") + NA
>
> is.na(x)
> is.na(y)
>
> x <- NA
> class(x) <- c("POSIXt", "POSIXct")
> is.na(x)
>
> # but these fail
>
> is.na(x) <- TRUE
> is.na(y) <- TRUE
>
> x[] <- NA
> y[] <- NA
>
> as.POSIXlt(NA)
> as.POSIXct(NA)
>
>
>
> --please do not edit the information below--
>
> Version:
> platform = i386-pc-mingw32
> arch = i386
> os = mingw32
> system = i386, mingw32
> status > major = 1
> minor = 5.1
> year = 2002
> month = 06
> day = 17
> language = R
>
> Windows 2000 Professional (build 2195) Service Pack 1.0
>
> Search Path:
> .GlobalEnv, package:ctest, Autoloads, package:base
>
> --
>
>
>
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._