Skip to Content

Simplify working with times and dates in R

David Smith's picture

R has some very powerful built-in features for working with dates, times, and time-zones. But power and flexibility rarely correlate with ease-of-use, and this is no exception. The lubridate package comes to the rescue, make things a bit easier when working with chronological data in R.

The paper Dates and Times Made Easy with lubridate provides in-depth explanations of its functionality, but a recent post on the r-statistics blog provides a handy guide to the latest version, with tips on:

  • how to convert string-formatted dates like "13-04-2011" or "04/13/2011" to date objects
  • how to extract time components (weekday, month, hour, second) etc. from chronological data
  • how to set and convert time zones for data with a time (hour-minute-second) component
  • how to calculate time intervals and other arithmetic operations on times and dates

To see these tips, read the post at the r-statistics blog linked below.

r-statistics blog: Do more with dates and times in R with lubridate 1.1.0