Parsing a large amount of characters into a POSIXct object

When trying to parse a large amount of datetime characters into POSXIct objects, it struck me that strftime and as.POSIXct where actually quite slow. When using the parsing functions from lubridate, these where a lot faster. The following benchmark shows this quite nicely.

We have a character vector xi, which contains about 2.3 million elements. When using strftime, this takes about 105 seconds on my MacBook pro:

If we switch to ymd_hms from lubridate, we get a very large performance increase:

ymd_hms is about a 120 times faster.

Tagged with: ,
Posted in R stuff
3 Comments » for Parsing a large amount of characters into a POSIXct object
  1. Hadley Wickham says:

    You might also try readr::parse_datetime().

  2. fasttime is also worth benchmarking. http://rforge.net/fasttime/

    It’s fast, but I dunno how it compares to lubridate.

1 Pings/Trackbacks for "Parsing a large amount of characters into a POSIXct object"
  1. […] Parsing a large amount of characters into a POSIXct object […]

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

*