age_calc: Age calculater (months)

Description Usage Arguments Details Value Examples

View source: R/misc.R

Description

Calculates ages in months with decimal days from date of birth until up to some point

Usage

1
age_calc(dob, ref, lub.fmt = lubridate::mdy)

Arguments

dob

Date of birth string that the function ymd and others like it can understand. Typically in the format "yyyy-mm-dd" or "yyyy/mm/dd"

ref

Reference date string. Either today's date or some other time after dob Defaults to today.

lub.fmt

Lubridate function for the input dates, such as ymd or any function that returns a POSIXct format. Defaults to mdy

Details

If you're going to use a reference date, make sure the format for both dob and ref are the same. For example, don't use ymd for dob and mdy for ref. You'll get wrong values.

Value

Numeric value of age in months

Examples

1
2
3
age_calc("01-10-2013")
age_calc(c("05-13-1983", "01-10-2013"), c("05-13-2000", "10-07-2014"))
age_calc("2013/01/10", lub.fmt=lubridate::ymd)

iamamutt/mejr documentation built on May 18, 2019, 1:27 a.m.