richgillin
4/8/2018 - 11:53 PM

18th birthday anomoly

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.