calc_age: Calculate age in years

Description Usage Arguments Value Author(s) Examples

Description

Calculate age in years

Usage

1
calc_age(dob, ref.date)

Arguments

dob

a vector of dates (should be date of births)

ref.date

a vector of dates (should be the reference date to calculate age)

Value

a numeric vector containing age in years

Author(s)

Daniel Gardiner (daniel.gardiner@phe.gov.uk)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# set dummy data

# set.seed(2)

data = data.frame(date.of.birth = sample(seq(as.Date('1900-01-01'), as.Date('1990-12-31'), by="day"), 30, replace = TRUE),
                  onset.date = sample(seq(as.Date('1991-01-01'), as.Date('2010-12-31'), by="day"), 30, replace = TRUE))

# use function

calc_age(dob = data$date.of.birth,
         ref.date = data$onset.date)

DanielGardiner/EpiFunc documentation built on July 25, 2019, 10:53 p.m.