month.distance | R Documentation |
The (integer) number of months between dates.
MonthDistance(dates, origin)
dates |
A vector of class |
origin |
A scalar of class |
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.
Steven L. Scott steve.the.bayesian@gmail.com
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.