[R] Bug in hist() when working with Dates ?

S. Nunes snunes at gmail.com
Mon Jun 1 17:45:54 CEST 2009


Hi,

It seems that hist() has a buggy behavior when breaking over "days".
The bug can be reproduced in a few steps:

> d=data.frame(date=c("2009-01-01", "2009-01-02", "2009-01-02"))
> d$date=as.Date(d$date)
> d$date
[1] "2009-01-01" "2009-01-02" "2009-01-02"

> h=hist(d$date, "days")
> h$count
[1] 3

Despite the fact that the original data contains 2 distinct days. The
call hist() only returns one "break", adding the occurrences of both
days. I would expect the last output to be: [1] 1 2.

I am using R version 2.9.0.

I would like to know if this behavior is correct or a bug?

Thanks in advance for your comments on this issue,

--
Sergio Nunes




More information about the R-help mailing list