r - create sequence of numbers with leading zeroes -


this question has answer here:

this question has been addressed using console.writelines function, not available in version of r , can't find package belongs to.

i trying create sequence of numbers 0-99 leading zeroes in format "xxx", numbers should 000, 001, 002... 099.

when use:

seq(000:099) 

r returns 1, 2, 3 etc.

is there simple way this? strikes me should far easier is.

this different previous answers need 2 zeroes in front of numbers 0-9 , 1 0 in front of numbers 10-99 whereas previous question asked 1 0 in front of numbers.

for example 1:100 leading zeroes 3 digits total:

sprintf('%0.3d', 1:100)   [1] "001" "002" "003" "004" "005" "006" "007" "008" "009" "010" "011" "012"  [13] "013" "014" "015" "016" "017" "018" "019" "020" "021" "022" "023" "024"  [25] "025" "026" "027" "028" "029" "030" "031" "032" "033" "034" "035" "036"  [37] "037" "038" "039" "040" "041" "042" "043" "044" "045" "046" "047" "048"  [49] "049" "050" "051" "052" "053" "054" "055" "056" "057" "058" "059" "060"  [61] "061" "062" "063" "064" "065" "066" "067" "068" "069" "070" "071" "072"  [73] "073" "074" "075" "076" "077" "078" "079" "080" "081" "082" "083" "084"  [85] "085" "086" "087" "088" "089" "090" "091" "092" "093" "094" "095" "096"  [97] "097" "098" "099" "100" 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -