10.7 Resources
This section provides pointers to resources on working with dates and times in R.
10.7.1 Dates and times
Read Chapter 16: Dates and times of the r4ds textbook (Wickham & Grolemund, 2017) and corresponding examples and exercises.
For background information, read the original lubridate paper “Dates and times made easy with lubridate” (Grolemund & Wickham, 2011) and see the Joda Time project (Colebourne & O’Neill, 2010) that inspired its time span concepts.
See the lubridate cheatsheet:
10.7.2 Standards
The following Wikipedia articles provide background information and links to important abbreviations, conventions, and corresponding standards on time:
Calendars are systems for organizing dates and units of time for religious, commercial, administrative, social, or scientific purposes. The year “2024” is defined by the Gregorian calendar used in most of the world today (i.e., as of 2024-10-16). It was introduced in October 1582, as a revision of the Julian calendar.
UTC stands for Universal Time, Coordinated, is the successor of Greenwich Mean Time (GMT) and does not change with changing seasons (i.e., uses no daylight saving time, DST).
ISO 8601 provides an international standard covering the exchange of date- and time-related data.
Leap year defines which calendar years contain an additional day (as February, 29, thus containing 366 days, rather than 365).
POSIX (aka. IEEE 1003 or ISO/IEC 9945) stands for Portable Operating System Interface and provides standards for maintaining compatibility between computer operating systems (based primarily on Unix).
Unix time explains how the Unix epoch was defined as 00:00:00 UTC on 1970-01-01 (1st of January 1970).
Other time-related abbreviations include AD vs. BC and AM vs. PM. As it happens, “12 AM” refers to midnight (00:00) and “12 PM” refers to noon (12:00).
10.7.3 R packages
There are several dedicated R packages for parsing dates and times:
anytime is an anything to “POSIXct” or “Date” converter (without requiring a
format
string).chron creates objects that allow calculations with dates and times, but ignore local options like time-zones, daylight saving time, etc.
hms provides a simple class for storing durations or time-of-day values and displaying them in the hh:mm:ss format. The hms package (Müller, 2023) is part of the tidyverse (see https://hms.tidyverse.org).
parsedate makes the very general date parsing utility from the git version control software available in R.
10.7.4 Instructions
The tutorial at https://www.r-bloggers.com/using-dates-and-times-in-r/ (by Bonnie Dixon, 2014) illustrates and compares various ways of handling dates and times in R.
Chapter 16: Dates and times of the r4ds textbook (Wickham & Grolemund, 2017) covers moslty lubridate and provides corresponding exercises.
The book Advanced R (Wickham, 2014a).
10.7.5 On Time
The following articles in The Stanford Encyclopedia of Philosophy provide readable introductions into the philosophy of time:
Since this chapter began with St. Augustine’s notorious quote, here is a philosophical wrap-up worth reading:
- What is time? (by John D. Norton, 2018-02-14) provides a lucid and sobering perspective on the nature of (seemingly deep questions about) time.
Finally, a remarkable feature of date and time is that every thing or event in our ordinary world has a beginning and an end. This chapter ends here.
[10_time.Rmd updated on 2024-10-16 22:07:18.1383 by hn.]