README.md

chilir

Functions for CHI numbers

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("graemegowans/chilir")

pad_chi()

Use pad_chi() to add a leading zero to a 9 character string. Other strings are left alone.

df <- tibble(chi_no = c("123456789", "1234567890", "123"))
df %>% mutate(padded_chi = pad_chi(chi_no))
#> # A tibble: 3 x 2
#>   chi_no     padded_chi
#>   <chr>      <chr>     
#> 1 123456789  0123456789
#> 2 1234567890 1234567890
#> 3 123        123

chi_check()

Use chi_check() to check for valid CHI.

df <- tibble(chi_no = c("0101209991", "3201209991", "0113209991", "3213209991",
                        "123", "12345678901", "?123456789", "A123456789", "0101209992"))
df %>% mutate(checked = chi_check(chi_no))
#> # A tibble: 9 x 2
#>   chi_no      checked          
#>   <chr>       <chr>            
#> 1 0101209991  <NA>             
#> 2 3201209991  invalid date     
#> 3 0113209991  invalid date     
#> 4 3213209991  invalid date     
#> 5 123         too short        
#> 6 12345678901 too long         
#> 7 ?123456789  invalid character
#> 8 A123456789  invalid character
#> 9 0101209992  invalid checksum


graemegowans/chilir documentation built on March 30, 2020, 10:14 p.m.