Skip to content
Prev 10567 / 15274 Next

xts and Sys.time() - very stange behaviour

This is an issue with precision and formatting when you convert to
character.  Here's a truly reproducible example:

require(xts)
options(digits.secs=6)
x <- xts(1, .POSIXct(1343845073.618 + 1e-3))
# Note that the index is correct, given the construction above
sprintf("%15.5f",.index(x))
# But also note that it doesn't print "correctly"
# (due to rounding/precision issues)
print(x)
# You can see how it's actually stored by using format
key <- as.character(index(x), format="%Y-%m-%d %H:%M:%OS6")
# There's the problem
print(key)

I don't know of a solution, other than "don't do that".

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
On Wed, Aug 1, 2012 at 1:08 PM, soren wilkening <me at censix.com> wrote: