Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upanytime is overwriting inputs #68
Comments
|
Yes, well it is standard R / Rcpp / SEXP-is-a-pointer behaviour. When a SEXP goes in, and we don't need to "cast" it is the variable being carried through. Here things are a little funny because we either will return a POSIXct (for |
|
In the middle case (for numeric) this is unavoidable. We just recast -- the numeric payload is unchanged but we just did a |
|
I think the fix would be to add a force clone (ie copy in different memory location) right here: https://github.com/eddelbuettel/anytime/blob/master/src/anytime.cpp#L459 That could be done, I just don't know if it is useful. I presume because R> x <- -662688000 + 3600*6 ## offset for my TZ
R> b <- as.POSIXct(x, origin="1970-01-01")
R> b
[1] "1949-01-01 CST"
R> x
[1] -662666400
R> |
|
Fix coming right up in a branch-that-will-be-a-PR-soon: R> library(anytime)
R> x <- -662688000 + 3600*6 ; x
[1] -662666400
R> b <- as.POSIXct(x, origin="1970-01-01"); b
[1] "1949-01-01 CST"
R> x
[1] -662666400
R> |
preserve numeric inputs (closes #68)
|
Nice! Thanks!! |
|
Looking at my last comment I copied the wrong example: R> library(anytime)
R> x <- -662688000 + 3600*6 ; x
[1] -662666400
R> b <- anytime(x); b
[1] "1949-01-01 CST"
R> x
[1] -662666400
R> |
This is such a useful package, thanks!
But when I use any of the functions on numeric output, it overwrites the input variable for some reason...
It works fine with integer or character input.
Here's an example: