R/lz_pad.R

Defines functions lz_pad

Documented in lz_pad

#' @name lz_pad
#'
#' @title Pad with zeroes on the left
#'
#' @description This just calls \code{\link[stringr]{str_pad}} to
#' pad each element of a character vector with zeros on the left side.
#' This is helpful when standardizing the length of numeric ID variables.
#'
#' @param string a vector.
#' @param width  minimum number of characters after padding.
#'
#' @return A character vector.
#' @export

lz_pad <-
  function(string, width){
    stringr::str_pad(string, width, side = "left", pad = "0")
  }
coletl/coler documentation built on May 12, 2021, 9:44 p.m.