Description Usage Arguments Value Examples
Calculate age in years from dates of birth.
1 | age_from_dob(dob, until = Sys.Date(), as_int = TRUE)
|
dob |
Vector of dates of birth. If not of class "Date", will attempt to
convert using |
until |
End-date used for age calculation. Defaults to current date
(based on |
as_int |
Logical indicating whether to return ages rounded down to the
nearest integer ( |
Vector of ages in units of years, either of class integer (if as_int = TRUE
) or numeric (as_int = FALSE
).
1 2 3 4 5 6 7 8 9 10 11 12 | dates_of_birth <- as.Date(
c("2001-04-05", "1976-10-24", "1990-03-15", "1943-12-08")
)
# by default returns integer ages
age_from_dob(dates_of_birth)
# use as_int = FALSE to return decimal values
age_from_dob(dates_of_birth, as_int = FALSE)
# calculate with end-point other than current date
age_from_dob(dates_of_birth, until = "2019-01-01")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.