Learn R Programming

bsts (version 0.9.10)

month.distance: Elapsed time in months

Description

The (integer) number of months between dates.

Usage

MonthDistance(dates, origin)

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.

Arguments

dates

A vector of class Date to be measured.

origin

A scalar of class Date.

Author

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

Examples

Run this code
  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)

Run the code above in your browser using DataLab