[Rd] Possible bug in how POSIXct is printed

Deonarine, Ajay Ajay.Deonarine at aig.com
Fri May 5 14:24:30 CEST 2017


Greetings R-devel group.  When dealing with Inf dates, as.POSIXct seems to return Inf, but is printed as NA:

> x1 <- as.POSIXct(Inf, origin = '1970-01-01')
> print(x1)
[1] NA
> is.na(x1)
[1] FALSE
> is.infinite(x1)
[1] TRUE
>

POSIXlt at least evaluates and prints the result consistently:

> x1 <- as.POSIXlt(Inf, origin = '1970-01-01')
> print(x1)
[1] NA
> is.na(x1)
[1] TRUE
>

I think the cause is due to format.POSIXct function calling format.POSIXlt, hence printing as NA, but actually storing an Inf.  I don't have an opinion on what the actual result of as.POSIXct(Inf) should be, as long as what's printed matches that value.

Thank you

	[[alternative HTML version deleted]]



More information about the R-devel mailing list