POSIX formats have problems with NA (PR#1732)

oehl_list@gmx.de oehl_list@gmx.de
Tue, 2 Jul 2002 20:51:07 +0200 (MET DST)


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