Created
April 6, 2019 18:33
-
-
Save alex-gable/bd1217d751f0a2fc1bf38ec4d7a3bbfa to your computer and use it in GitHub Desktop.
date differences using lubridate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(lubridate) | |
bday <- lubridate::as_date("2000-09-15") | |
today <- lubridate::as_date("2018-09-15") | |
tomorrow <- lubridate::as_date("2018-09-16") | |
bday%--%today / lubridate::years(1) | |
# [1] 18 | |
as.numeric(as.duration(bday%--%today)) / (60*60*24*365.25) | |
# [1] 17.99863 | |
bday%--%tomorrow / lubridate::years(1) | |
# [1] 18.00274q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment