Skip to contents

Calculate age in years, months, or days

Usage

age_calc(dob, enddate = Sys.Date(), units = "years", precise = TRUE)

Arguments

dob

Date of birth

enddate

End date for age calculation (default is Sys.Date())

units

Units for age calculation (default is "years"). Can be c("days", "months", "years")

precise

Option to calculate age precisely (default is TRUE)

Value

Age

References

Becker, J.P. (2020). eeptools: An R Package for Teaching and Learning Ecology and Evolutionary Biology. Journal of Statistical Software, 93(2), 1-27. doi: 10.18637/jss.v093.i02

See also

Examples

age_calc(dob = as.Date("1995-04-25"), enddate = as.Date("2020-04-25"), units = "years")
#> [1] 25
# Kim Larsen (cpr is known from album)
  dob<-as.Date("1945-10-23")
  date<-as.Date("2018-09-30")
  trunc(age_calc(dob,date))
#> [1] 72