Learn R Programming

eye (version 1.3.0)

getage: getage

Description

calculates age in years, as durations or periods

Usage

getage(from_date, to_date = lubridate::now(), period = FALSE, dec = 1)

Value

Numeric vector

Arguments

from_date

start date

to_date

end date

period

Calculating period (TRUE) or duration (FALSE- default)

dec

How many decimals are displayed

Author

Antoine Fabri and Tjebo Heeren

See Also

OP on stackoverflow from which this function was inspired. Read about periods and durations

Examples

Run this code
getage("1984-10-16")

dob <-  c("1984-10-16", "2000-01-01")
test_date <-  as.Date(dob) + c(15000, 20000)
getage(dob, test_date)

Run the code above in your browser using DataLab