Description Usage Arguments Value Author(s) Examples
Calculate age in years
1 | calc_age(dob, ref.date)
|
dob |
a vector of dates (should be date of births) |
ref.date |
a vector of dates (should be the reference date to calculate age) |
a numeric vector containing age in years
Daniel Gardiner (daniel.gardiner@phe.gov.uk)
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.