2022-09-22 14:20:46 +02:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/age_calc.R
\name{age_calc}
\alias{age_calc}
2023-01-03 14:12:12 +01:00
\title{Calculate age in years, months, or days}
2022-09-22 14:20:46 +02:00
\usage{
age_calc(dob, enddate = Sys.Date(), units = "years", precise = TRUE)
}
\arguments{
2023-01-03 14:12:12 +01:00
\item{dob}{Date of birth}
2022-09-22 14:20:46 +02:00
2023-01-03 14:12:12 +01:00
\item{enddate}{End date for age calculation (default is Sys.Date())}
2022-09-22 14:20:46 +02:00
2023-01-03 14:12:12 +01:00
\item{units}{Units for age calculation (default is "years").
Can be c("days", "months", "years")}
2022-09-22 14:20:46 +02:00
2023-01-03 14:12:12 +01:00
\item{precise}{Option to calculate age precisely (default is TRUE)}
2022-09-22 14:20:46 +02:00
}
\value{
2023-01-04 14:33:48 +01:00
numeric vector length 1
2022-09-22 14:20:46 +02:00
}
\description{
2023-01-03 14:12:12 +01:00
Calculate age in years, months, or days
2022-09-22 14:20:46 +02:00
}
\examples{
2023-01-03 14:12:12 +01:00
age_calc(dob = as.Date("1995-04-25"), enddate = as.Date("2020-04-25"), units = "years")
2022-09-22 14:20:46 +02:00
# Kim Larsen (cpr is known from album)
2022-09-22 19:57:12 +02:00
dob<-as.Date("1945-10-23")
2022-09-22 14:20:46 +02:00
date<-as.Date("2018-09-30")
trunc(age_calc(dob,date))
}
2023-01-03 14:12:12 +01:00
\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
}
\seealso{
\code{\link[lubridate]{time_length}}
}
2022-09-22 14:20:46 +02:00
\keyword{age}
2023-01-03 14:12:12 +01:00
\keyword{date}
\keyword{time}