1.4 Date and time
Dates are standardized in the format YYYY-MM-DD
(ISO-8601), and when contain time are of the form YYYY-MM-DD HH:MM:SS
. This procedure facilitates the programming and organization of the material, ensuring that the files named in this way are ordered chronologically in any system. The lubridate
(Grolemund and Wickham 2011) package provides a number of useful functions for dealing with temporal elements.
library(lubridate)
# Apollo 11 lands on the Moon on July 20, 1969 at 20:17 UTC (Coordinated Universal Time)
(apollo11 <- ymd_hms('1969-07-20 20:17:00'))
## [1] "1969-07-20 20:17:00 UTC"
## [1] 1969
## [1] 7
## [1] 20
## [1] 20
## [1] 17
## [1] 0
## [1] Sun
## Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
## [1] "1969-07-20 17:17:00 -03"
## Time difference of 19849.7 days
References
Grolemund, Garrett, and Hadley Wickham. 2011. “Dates and Times Made Easy with lubridate.” Journal of Statistical Software 40 (3): 1–25. https://www.jstatsoft.org/v40/i03/.