Skip to content

pad leading zeros in front of strings

1 message · R. Michael Weylandt

#
Please do reply to the list -- I'm not on Windows so someone else will
have to pick the question up to help you out.

It's not great, but you could do something like

zeroPad <- function(str, len.out, num.zeros = len.out[1] - nchar(str)){
   paste0(paste(rep("0", num.zeros), collapse = ""), str)
}

as a temporary work-around. Probably possible to vectorize that pretty
easily as well.

Best,
Michael
On Tue, May 22, 2012 at 2:50 PM, Hui Du <Hui.Du at dataventures.com> wrote: