This was a long and difficult chapter, but not because the functions and packages of R are difficult, but rather because the domain and representation of dates and times provide substantial challenges. As we have seen, dealing with times requires knowing and navigating many cultural and local conventions, some peculiarities, and various standards. An intellectually intriguing aspect of this topic is that solving tasks with date- and time-related data requires a solid conceptual understanding of time (e.g., points vs. spans of time) and various notions of time spans (e.g., durations, periods, and intervals).
After working through this chapter, you are able to:
- understand the basic units of dates and times,
- distinguish between different time zones and notions of time spans,
- understand and use essential date and time classes of base R,
- understand and use key date and time functions of lubridate,
- create date and time variables from various inputs,
- perform basic computations with date and time variables,
- use simple ds4psy functions to query dates and times.
For an overview of manipulating dates and times with lubridate, take a look at the R Studio Cheat Sheet to check which commands you are now familiar with and which others you can still discover in the future:
Let’s test our knowledge and skills on creating and manipulating dates and times by completing the following exercises.