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/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to