R/npers_to_bcsi.R

Defines functions npers_to_bcsi

Documented in npers_to_bcsi

#' Transforming N_PERS to BCSI_ID
#'
#' @param npers An N_PERS to transform to BCSI_ID
#'
#' @return A character string with 10 digit BCSI ID
#' @import stringr
#' @export
#'
#' @examples
#' npers_to_bcsi(0039249861)
#' npers_to_bcsi(39249861)



npers_to_bcsi <- function(npers) {

  if(anyNA(as.numeric(npers))) {
    warning("npers contains non-numeric characters")
  }

  npers <- str_pad(npers, side ="left", width = 10, pad = "0")
  bcsi <- str_trunc(npers, width = 8, side = "right", ellipsis = "")
  bcsi <- str_pad(bcsi, width = 10, side = "left", pad = "0")
}
suzanbaert/kycdata documentation built on May 23, 2019, 6:08 p.m.