Skip to contents

Check age values in cause-of-death data based on CoDEdit rules

Usage

cod_check_age(age_value, age_type, age_type_code = c("D", "M", "Y"))

Arguments

age_value

An integer value or vector of values for age based on the CoDEdit rules.

age_type

A vector of values for age type based on the CoDEdit rules. This should either be "D" for age in days, "M" for age in months, or "Y" for age in years. If values are different from these, then age_type_code should be specified to correspond to the day, month, and year values of age_type.

age_type_code

A character or integer vector of 3 values that indicate which values are to be considered pertaining to days (first value in the vector), to months (second value in the vector), or years (third value in the vector).

Value

A tibble with number of rows equal to length of age_value and two columns for age_check and age_check_note.

Examples

cod_check_age(120, "Y")
#> # A tibble: 1 × 2
#>   age_check age_check_note                       
#>       <int> <fct>                                
#> 1         0 No issues with age value and age type
cod_check_age(28, "D")
#> # A tibble: 1 × 2
#>   age_check age_check_note                                              
#>       <int> <fct>                                                       
#> 1         1 Should probably be age value of 1 and age type of months (M)
cod_check_age(32, "D")
#> # A tibble: 1 × 2
#>   age_check age_check_note                                                      
#>       <int> <fct>                                                               
#> 1         2 Should probably be converted to age value of age type months (M) no…