month.distance function

Elapsed time in months

Elapsed time in months

The (integer) number of months between dates. 1.0

MonthDistance(dates, origin)

Arguments

  • dates: A vector of class Date to be measured.
  • origin: A scalar of class Date.

Returns

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

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)
  • Maintainer: Steven L. Scott
  • License: LGPL-2.1 | MIT + file LICENSE
  • Last published: 2024-01-17

Useful links