Time between dates
time.RdCalculates time between two date vectors.
Examples
#----------------------------------------------------------------------------
# time() examples.
#----------------------------------------------------------------------------
library(bkmisc)
time1 <- as.Date(c("1992-02-27", "1992-02-27", "1992-01-14", "1992-02-28", "1992-02-01"))
time2 <- as.Date(c("1992-02-28", "1992-03-27", "1992-07-14", "1992-04-15", "1993-02-01"))
time3 <- as.POSIXct(c("1992-02-27", "1992-02-27", "1992-01-14", "1992-02-28", "1992-02-01"))
time4 <- as.POSIXct(c("1992-02-28", "1992-03-27", "1992-07-14", "1992-04-15", "1993-02-01"))
time(start = time1, stop = time2, units = "days")
#> [1] 1 29 182 47 366
time(start = time3, stop = time4, units = "months")
#> [1] 0.03285421 0.95277207 5.97809719 1.54277892 12.02464066
time(start = time1, stop = time4, units = "years")
#> [1] 0.003308236 0.079968058 0.498745152 0.129135295 1.002623774