From h.wickham at gmail.com  Wed Oct 21 23:57:45 2015
From: h.wickham at gmail.com (Hadley Wickham)
Date: Wed, 21 Oct 2015 16:57:45 -0500
Subject: [Rd] Confusing print method for Inf dates
Message-ID: <CABdHhvGAUA_D6t2MB6xWr-B5EWeTxB+kELNDTTzuTyC3-AdzhA@mail.gmail.com>

x <- as.Date(Inf, origin = "1970-01-01")
x
#> [1] NA
str(x)
#>  Date[1:1], format: NA
unclass(x)
#> [1] Inf

It's not clear what the correct behaviour is. The documentation for
?Date has: "It is intended that the date should be an integer,", which
suggests that -Inf and Inf are not valid dates. But if that's true the
behaviour for max.Date() needs some thought:

max(as.Date(NA), na.rm = TRUE)
#> Warning in max.default(structure(NA_real_, class = "Date"), na.rm = TRUE):
#> no non-missing arguments to max; returning -Inf
#> [1] NA

If dates are integers, then there is no date that is smaller than all
other dates, so it's not clear what max() should return - NA?

Hadley

-- 
http://had.co.nz/



[Rd] Confusing print method for Inf dates
Hadley Wickham