Skip to content
Prev 26963 / 63434 Next

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

Kurt.Hornik at wu-wien.ac.at wrote:
34; VDF: 7.0.0.210; host: fsme.wu-wien.ac.at)
wu-wien.ac.at
Again? ;-)

The bug is here:
function (..., na.rm =3D FALSE, finite =3D FALSE)
{
    x <- c(..., recursive =3D 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") ){....}


--=20
   O__  ---- Peter Dalgaard             =C3=98ster Farimagsgade 5, Entr.B=

  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327=
918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327=
907