date_to_age: Convert Dates to Ages

Description Usage Arguments Value Author(s) Examples

Description

Convert dates to ages.

Usage

1
date_to_age(dob, refdate = Sys.time())

Arguments

dob

'Date of Birth'

refdate

Reference date to compare x with. Defaults to the current date

Value

Numeric, 'whole number' ages

Author(s)

Brendan Rocks rocks.brendan@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# The argument can take a single age
date_to_age("1952-04-29")

# Or a whole vector!
data(test_data)
test_data$age <- date_to_age(test_data$dob)

# Historical ages, too. How old were these people yesterday?

test_data$age <- date_to_age(test_data$dob, Sys.Date() - 1)

brendan-r/brocks documentation built on May 13, 2019, 5:08 a.m.