age: Calculate age

View source: R/alder.R

ageR Documentation

Calculate age

Description

By default, calculates the typical "age in years", with a floor applied so that you are, e.g., 5 years old from 5th birthday through the day before your 6th birthday. Set floor = FALSE to return decimal ages, and change units for units other than years.

Usage

age(dob, ageDay = Sys.Date(), units = "years", floor = TRUE)

Arguments

dob

date-of-birth, the day to start calculating age.

ageDay

the date on which age is to be calculated.

units

unit to measure age in. Defaults to "years". Passed to duration.

floor

boolean for whether or not to floor the result. Defaults to TRUE.

Value

Age in units. Will be an integer if floor = TRUE.

Examples

mydob <- as.Date('1983-10-20')
age(mydob)
age(mydob, units = "minutes")
age(mydob, floor = FALSE)


Rapporteket/muskel documentation built on June 9, 2025, 4:49 p.m.