Things I forget: padding integers with zeroes

2018/11/04

So simple, so difficult to remember.

x <- c(5, 15, 2015)
sprintf(sprintf("%03d", x))
## [1] "005"  "015"  "2015"

Source: SO post