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 upConvert POSIXct to Date directly #2
Conversation
As of R-3.5.1, converting from POSIXct to Date creates an intermediate POSIXlt vector. This uses a non-trivial amount of memory. Directly converting from POSIXct to Date uses less memory and is roughly twice as fast. This solution is a combination of asPOSIXlt and POSIXlt2D from RCore. The functions are essentially concatenated, with the extraneous parts removed. The function name 'asDatePOSIXct' differs from the other rapi* names because it's not a RCore function. The name isn't as.Date.POSIXct() to avoid clashes with the current (or future) S3 method.
Codecov Report
@@ Coverage Diff @@
## master #2 +/- ##
==========================================
+ Coverage 53.24% 54.67% +1.42%
==========================================
Files 5 6 +1
Lines 971 1017 +46
==========================================
+ Hits 517 556 +39
- Misses 454 461 +7
Continue to review full report at Codecov.
|
|
Looks fabulous, and helpful. |
As of R-3.5.1, converting from POSIXct to Date creates an intermediate
POSIXlt vector. This uses a non-trivial amount of memory. Directly
converting from POSIXct to Date uses less memory and is roughly twice
as fast.
This solution is a combination of asPOSIXlt and POSIXlt2D from RCore.
The functions are essentially concatenated, with the extraneous parts
removed.
The function name 'asDatePOSIXct' differs from the other rapi* names
because it's not a RCore function. The name isn't as.Date.POSIXct() to
avoid clashes with the current (or future) S3 method.