Date and Time Manipulation in R: Fundamentals

In this second lesson of our course on strings, dates and times in R, you'll learn the fundamentals of working with dates and times in R.

Dates and times appear everywhere in an analysis context. Businesses want to see if a new advertising campaign has made a significant effect on their sales, so they would look for patterns before and after the campaign. Accelerometers in your phone keep track of your activity through time, so you can analyze how active you are throughout the day.

R doesn't have a built-in data type for dates and times, but it has well established functions that smooth the process of using them. Throughout this mission, we'll be using the lubridate package.

In the mission, you'll learn how dates and times are represented in Unix, how to extract a particular component from a datetime, how to calculate timespans and durations, and how to manipulate timezones.

By the end of this mission, you'll be comfortable with the fundamentals required to work with dates and times effectively in R.


  • Learn to use the lubridate package to work with dates and times.
  • Calculate timespans, durations, etc.
  • Manipulate timezones using R.

Mission Outline

  1. Introduction
  2. Data Representation
  3. Time Representation
  4. Unix Representation
  5. Component Extraction
  6. Time Span Calculations
  7. Durations and Periods
  8. Time Zone Manipulation
  9. Next Steps

Course Info:


This course requires a Basic subscription and includes three missions and one guided project.  It is the fourth course in the Data Analyst in R learning path.


Take a Look Inside