#' 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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.