R/zero_paste.R

Defines functions zero_paste

zero_paste <-
function(x) {
  maxx <- max(x)
  max_char <- nchar(as.character(maxx))
  newx <- as.character(x)
  for (i in 1:length(newx)) {
    ii <- newx[i]
    char_i <- nchar(ii)
    zeros <- paste0(rep("0", (max_char - char_i)), collapse = "")
    ii <- paste(zeros, ii, sep = "")
    newx[i] <- ii
  }
  return(newx)
}

Try the chinese.misc package in your browser

Any scripts or data that you put into this service are public.

chinese.misc documentation built on Sept. 13, 2020, 5:13 p.m.