month.distance: Elapsed time in months

Description Usage Arguments Value Author(s) Examples

Description

The (integer) number of months between dates.

Usage

1
   MonthDistance(dates, origin)

Arguments

dates

A vector of class Date to be measured.

origin

A scalar of class Date.

Value

Returns a numeric vector giving the integer number of months that have elapsed between origin and each element in dates. The daily component of each date is ignored, so two dates that are in the same month will have the same measured distance. Distances are signed, so months that occur before origin will have negative values.

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

Examples

1
2
3
4
5
6
  dates <- as.Date(c("2008-04-17",
                     "2008-05-01",
                     "2008-05-31",
                     "2008-06-01"))
  origin <- as.Date("2008-05-15")
  MonthDistance(dates, origin) ==  c(-1, 0, 0, 1)

michelletran/bsts documentation built on March 29, 2020, 12:58 a.m.