calculate_age: Calculate age from date of birth

View source: R/calculate_age.R

calculate_ageR Documentation

Calculate age from date of birth

Description

Calculate age from date of birth

Usage

calculate_age(dob, date = "today", date_format = "ymd", units = "years")

Arguments

dob

Date of birth, preferably "YYYY-MM-DD" format

date

Date to calculate age from, default is today

date_format

defaults to "ymd" "YYYY-MM-DD" format

units

units to return age in, default is "years"; other options are "days", "weeks", "months"

Value

age in years

Examples

calculate_age(dob = "Jan 5, 1960", date_format = "mdy")
calculate_age(dob = "1/5/1960", date_format = "mdy")
calculate_age(dob = "1960-01-05", date_format = "ymd")
calculate_age(dob = "1960-01-05", date_format = "ymd", units = "days")
calculate_age(dob = "1960-01-05", date_format = "ymd", units = "weeks")

JMLuther/tabletools documentation built on July 1, 2024, 2:01 p.m.