[Rd] Confusing print method for Inf dates

Hadley Wickham h.wickham at gmail.com
Wed Oct 21 23:57:45 CEST 2015

x <- as.Date(Inf, origin = "1970-01-01")
#> [1] NA
#>  Date[1:1], format: NA
#> [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?



More information about the R-devel mailing list