I am reading a CSV with fread
(as it is quicker than read_csv
method), timestamp column is taken as character
type.
I want to convert it to POSIXct
with:
as.POSIXct(strptime(rawTime, "%Y-%m-%d %H:%M:%OS"))
But this POSIXct
call is very slow.
Is there any quicker alternatetive to this?
We can use fastPOSIXct
from fasttime
library(fasttime)
str1 <- rep("2015-01-01", 1e6)
system.time(fastPOSIXct(str1))
# user system elapsed
# 0.08 0.00 0.08
system.time(as.POSIXct(str1))
# user system elapsed
# 24.80 0.26 25.33
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With