How to convert the character string "January 01, 2014" to POSIXct most effectively, i.e. "2014-01-01" yyyy-mm-dd

I already have a partial answer to the problem here, which I understand how this is explained: How to most effectively restructure a character string for quick time in data.table

However, the task has been expanded and must deal with a change in the original formatting.

I have a large dataset with a character class date column in the form:

01 Jan 2014

or

dd MMM yyyy

What I want to restructure for filing in fastPOSIXct, which only accepts character input in POSIXctorder:

yyyy-mm-dd

, , fast.time. , , , ? ? , month.abb . , ?

+4
1

lubridate:

x <- "01 Jan 2014"
x
[1] "01 Jan 2014"
library(lubridate)
dmy(x)
[1] "2014-01-01 UTC"

, lubridate tz. , . OlsonNames()

Benchmark

, micro benchmark lubridate fasstime.

library(micro benchmark)
microbenchmark(dmy(x), times = 10000)
Unit: milliseconds
   expr      min      lq     mean   median      uq     max neval
 dmy(x) 1.992639 2.02567 2.142212 2.041514 2.07153 39.1384 10000

options(lubridate.fasttime = T)

microbenchmark(dmy(x), times = 10000)
Unit: milliseconds
   expr      min      lq     mean   median       uq      max neval
 dmy(x) 1.993326 2.02488 2.136748 2.039467 2.065326 163.2008 10000
+5

All Articles