chi_age: Determine an age from Community Health Index (CHI) number

Description Usage Arguments Value Examples

View source: R/chi.R

Description

Determine an age from Community Health Index (CHI) number

Usage

1
chi_age(.data, ref_date, cutoff_2000 = 20)

Arguments

.data

Character. A vector of CHIs as characters/strings.

ref_date

Dates. Single date or vector with same length as .data.

cutoff_2000

Integer. Two-digit year before which is considered 2000s.

Value

A vector of ages.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(dplyr)
# These CHIs are not real.
chi = c("1009701234", "1811431232", "1304496368")

# Age today
chi_age(chi, Sys.time())

# Age on a single date
library(lubridate)
chi_age(chi, dmy("11/09/2018"))

# Age on a vector of dates
dates = dmy("11/09/2018",
            "09/05/2015",
            "10/03/2014")
chi_age(chi, dates)
# From tibble
tibble(chi = chi) %>%
  mutate(
    age = chi_age(chi, Sys.time())
  )

SurgicalInformatics/chiTools documentation built on Feb. 5, 2021, 8:28 p.m.