dates | R Documentation |
A set of helper functions for dealing with dates in a typical actuarial analysis context.
Derive the number of months elapsed between two dates.
end_of_month(date)
start_of_month(date)
extract_date(string)
elapsed_months(end_date, start_date)
date |
character or date representation of a date. |
string |
string to extract a date from |
end_date |
end date |
start_date |
start date |
end_of_month
returns last day of the month given.
start_of_month
returns the first day of the month given.
extract_date
returns a date object extracted from the provided string.
numeric
as.Date()
, lubridate::ceiling_date()
, lubridate::floor_date()
,
flipTime::AsDate()
# character input
start_of_month("2020-08-13")
end_of_month("2017-10-20")
# can handle human-readable dates also
start_of_month("July 7, 1999")
end_of_month("February 5, 2019")
# date input
start_of_month(as.Date("2020-08-13"))
end_of_month(as.Date("2020-10-20"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.