[R] zoo: bug with unique for yearmon

Johann Hibschman jhibschman at gmail.com
Mon Nov 9 17:58:40 CET 2009


I'm using R 2.10.0, with zoo 1.5-8. The release notes for zoo 1.5-8
claim a bug with unique for yearmon objects has been fixed, but I'm
still having problems.

Browse[1]> tmp2
[1] "Dec 1996" "Dec 1996"
Browse[1]> unique(tmp2)
[1] "Dec 1996" "Dec 1996"
Browse[1]> unique(unique(tmp2))
[1] "Dec 1996"
Browse[1]> as.numeric(tmp2) - (1996 + 11/12)
[1]  0.000000e+00 -2.273737e-13

Is there a work-around? I had been using an integer months-since-2000
as my month index, so I can go back to doing that, but it's much
harder to interpret those numbers.

Clearly, I'm being bitten by the floating-point representation, but
the only "complex" thing I did was to manually lag a time series by
assigning date <- date + 1/12, and I was hoping that the yearmon class
would apply some magic to normalize the representation.

Regards,
Johann Hibschman




More information about the R-help mailing list