I suspect this is a rounding / floating point issue:
Browse[2]> print(head(as.numeric(order.by)), digits = 20) [1] 1332234170.0009999275 1332234170.0009999275 1332234170.0009999275 [4] 1332234170.0009999275 1332234170.0009999275 1332234170.0009999275
This was achieved by debugging xts() when called
foo <- xts(1:180, rep(as.POSIXlt("2012-03-20 09:02:50.001"), 180), unqiue = FALSE)
but you can clearly see the problem through
> print(as.numeric(as.POSIXlt("2012-03-20 09:02:50.001"))) [1] 1332234170 > print(as.numeric(as.POSIXlt("2012-03-20 09:02:50.001")), digits = 20) [1] 1332234170.0009999275
Indicating that your fractional number of seconds cannot be created and not saved exactly .001 milliseconds. If truncation like 3 dp will contain .002 as it is saved as:
> print(as.numeric(as.POSIXlt("2012-03-20 09:02:50.002")), digits = 20) [1] 1332234170.0020000935
Truncating or rounding to 3 dp will save the .002 part. One of the problems you have to deal with when working with computers.
Note that this seems to be a problem in the printed representation of indexes:
> print(as.numeric(index(foo)[1]), digits = 20) [1] 1332234170.0009999275
Accuracy (with floating point problems) is stored in the actual object storing index times - you simply cannot see this when printing time to the console.
source share