This was a fairly 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 contains substantial challenges. As we have seen, dealing with times requires knowing and navigating a large number of cultural and local conventions, some peculiarities, and various standards. Perhaps the most 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 multiple 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 on 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.