library(stringr) str_pad(anim, 6, pad = "0") ## [1] "025499" "025500" "025501" "025502" "025503" "025504"