R/getCurrentAge.R

Defines functions getCurrentAge

Documented in getCurrentAge

#' Age in years using the provided birthdate.
#'
#' Assumes current date for calculating age.
#'
## Copyright(c) 2017-2024 R. Mark Sharp
## This file is part of nprcgenekeepr
#'
#' @return Age in years using the provided birthdate.
#'
#' @param birth birth date(s)
#' @importFrom lubridate duration interval today
#' @export
#' @examples
#' library(nprcgenekeepr)
#' age <- getCurrentAge(birth = as.Date("06/02/2000", format = "%m/%d/%Y"))
getCurrentAge <- function(birth) {
  as.numeric(interval(start = birth, end = today()) /
    duration(num = 1, units = "years"))
}
rmsharp/nprcmanager documentation built on Feb. 2, 2025, 12:45 a.m.