[Rd] Issue with aggregate.ts and/or %\% on Windows

Patrick Aboyoun paboyoun at fhcrc.org
Tue Apr 20 01:31:31 CEST 2010


I've stumbled across an issue with aggregate.ts that either is due to a 
misuse of %/% or something deeper relating to numerical precision on 
Windows. The test code is

x <- rep(6:10, 1:5)
as.vector(aggregate(as.ts(x), FUN = mean, ndeltat = 5))

On Linux and Mac I get the correct answer

 > x <- rep(6:10, 1:5)
 > as.vector(aggregate(as.ts(x), FUN = mean, ndeltat = 5)
[1]  7.2  8.8 10.0

 > sessionInfo()
R version 2.11.0 RC (2010-04-18 r51771)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


and on Windows I get an incorrect answer

 > x <- rep(6:10, 1:5)
 > as.vector(aggregate(as.ts(x), FUN = mean, ndeltat = 5))
[1] 7.0 8.5 9.5

 > sessionInfo()
R version 2.11.0 beta (2010-04-11 r51685)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


Walking through the aggregate.ts code I found this difference is due to 
what 1 %/% 0.2 produces on the different platforms.

On Mac and Linux I get

 > 1 %/% 0.2
[1] 5

and on Windows I get

 > 1 %/% 0.2
[1] 4


I don't know if %/% supports floating point operands so I'm not sure how 
to report this issue, but here it is anyway.


Patrick



More information about the R-devel mailing list