Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save richgillin/f9f11699ffe7335d0eeccbad75252574 to your computer and use it in GitHub Desktop.
Save richgillin/f9f11699ffe7335d0eeccbad75252574 to your computer and use it in GitHub Desktop.
18th birthday anomoly
a1 <- as.Date("1985-01-21")
a1 <- as.POSIXlt(a1)
a1$year <- a1$year+18; a1
## [1] "2003-01-21 UTC"
# with lubridate
library(lubridate)
a2 <- as_date("1985-01-21")
a_18 <- a2 + dyears(18); a_18
## [1] "2003-01-17"
## Four days difference between r-base (+Fei Teng) and tidyverse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment