R/pad_chi.R

Defines functions pad_chi

Documented in pad_chi

#' Pad CHI
#'
#' Pad a 9 character CHI number to 10 characters
#'
#' @param to_pad character vector of CHI numbers
#' @return character
#' @export
#' @examples pad_chi(c("123456789","1234567890"))
pad_chi <- function(to_pad){

  #stop if input is not character
  if(inherits(to_pad, "character") != TRUE) {
    stop("input should be character class - try adding col_types = 'c' to read_csv")
  }

  ifelse(nchar(to_pad) == 9,
         paste0("0", to_pad),
         paste0(to_pad))
}
graemegowans/chilir documentation built on March 30, 2020, 10:14 p.m.