I have some lovely nanotimes:
> mynames
[1] "2020-04-15T00:29:00.000000000+00:00" "2020-04-15T00:33:00.000000000+00:00"
Which I'd like to add as dimnames to my array:
> a
[,1] [,2]
[1,] NA NA
[2,] NA NA
However, they seem to be converted into rolled over strings:
> dimnames(a)[1] <- list(values=mynames)
> a
[,1] [,2]
1.39309697650764e-202 NA NA
1.39315136717363e-202 NA NA
> dimnames(a)
[[1]]
[1] "1.39309697650764e-202" "1.39315136717363e-202"
How can I keep my dimname assignment as nanotime/integer64s? Or if they are forced to character to be dimnames, how can I at least keep them from being strings of incorrect numbers?
You can see for example that these fail to round-trip back to suitable times:
> nanotime(dimnames(a)[1][[1]][1])
Error in RcppCCTZ::parseDouble(x, fmt = format, tz = tz) :
Parse error on 1.39309697650764e-202
The documentation of
dimnamesstates that thevalueis coerced tocharacter. To do all the coercing back and from tonanotimewhich is based oninteger64, you can first coerce yournanotimetointeger64and then tocharacter. Then the back coercion works: