Adding Time To A Date

Want to learn more? I recommend working through: R for Data Science, R Cookbook, and R Graphics Cookbook.

# load the lubridate package
library(lubridate)
# create a date variable
date.ex <- dmy("1/1/2001")
date.ex
[1] "2001-01-01 UTC"
# add 45 days to a date
date.ex.2 <- date.ex + days(45)
date.ex.2
[1] "2001-02-15 UTC"
# add six weeks to a date
date.ex.3 <- date.ex + weeks(6)
date.ex.3
[1] "2001-02-12 UTC"