Why are lubridate functions so slow when compared with as.POSIXct?

前端 未结 2 1530
挽巷
挽巷 2020-12-14 16:53

As the title goes. Why is the lubridate function so much slower?

library(lubridate)
library(microbenchmark)

Dates <- sample(c(dates = format(seq(ISOdate(         


        
2条回答
  •  感情败类
    2020-12-14 17:58

    @Tyler's answer is correct. Here's some more info including a tip on making lubridate faster - from the help file:

    " Lubridate has an inbuilt very fast POSIX parser, ported from the fasttime package by Simon Urbanek. This functionality is as yet optional and could be activated with options(lubridate.fasttime = TRUE). Lubridate will automatically detect POSIX strings and use fast parser instead of the default strptime utility. "

提交回复
热议问题