Learn R Programming

timeplyr (version 1.1.0)

age_years: Accurate and efficient age calculation

Description

Correct calculation of ages in years using lubridate periods. Leap year calculations work as well.

Usage

age_years(start, end = if (is_date(start)) Sys.Date() else Sys.time())

age_months(start, end = if (is_date(start)) Sys.Date() else Sys.time())

Value

Integer vector of age in years or months.

Arguments

start

Start date/datetime, typically date of birth.

end

End date/datetime. Default is current date/datetime.