Skip to content
Prev 26962 / 63434 Next

[Kurt.Hornik@wu-wien.ac.at: Re: range( <dates>, na.rm = TRUE )] (PR#10508)

Kurt.Hornik at wu-wien.ac.at wrote:
Again? ;-)

The bug is here:
function (..., na.rm = FALSE, finite = FALSE)
{
    x <- c(..., recursive = TRUE)
    if (is.numeric(x)) {
        if (finite)
            x <- x[is.finite(x)]
        else if (na.rm)
            x <- x[!is.na(x)]
    }
    c(min(x), max(x))
}
<environment: namespace:base>

Objects of class Date are not considered numeric, so we end up taking
min and max without removing NA.

One solution could be

if (is.numeric(x) || inherits(x, "Date") ){....}