as.POSIXct() can be slow as molasses. Have you ever tried to import a million timestamps in R? Luckily, Simon Urbanek has gifted useRs with fasttime, an R library for quickly parsing timestamps using string manipulation. Install it with:
install.packages('fasttime', type='source', repos='http://rforge.net')
fasttime contains one function, fastPOSIXct, that is restricted to parsing GMT timestamps after 1970-01-01. For many of us dealing with lots of recently acquired time-series data, that’s no problem.
If your timestamps aren’t in GMT, don’t despair. Make sure they’re formatted as “YYYY-mm-dd HH:MM:SS” in a local timezone; then, just pass tz=”America/Los_Angeles” (or whatever) to this little helper function. If your timestamps are formatted differently, then string manipulation with stringr should help you whip them into shape.
It should be almost 50x faster than as.POSIXct.
Of course, if you find a bug, let me know!