get_age: Calculate age

View source: R/get_age.R

get_ageR Documentation

Calculate age

Description

Takes two Date objects and calculates age based on difftime (in days) divided by 365.2425 days per year (for age in years) or 30.4375 days per month (for age in months).

Usage

get_age(birthdate, current_date, units = c("years", "months"))

Arguments

birthdate

Date object giving the date of birth

current_date

Date object giving the date from which age is to be calculated

units

The units in which age should be reported

Value

Numeric value giving age in the specified units.

Examples

get_age(as.Date("2000-01-01"), Sys.Date(), "years")

PAutilities documentation built on Aug. 21, 2022, 9:05 a.m.