Home > front end >  Generate numbers from 0000 to 9999 with 4 digits
Generate numbers from 0000 to 9999 with 4 digits

Time:10-19

I am having a bit of trouble changing the format of my integer. I need to display numbers from 0000 to 9999 (10000 numbers)in R Language. Would someone know how could I do this displaying the 4 digits (0001 0002...9998 9999)?

CodePudding user response:

Make strings with extra zeros "padded" on the left with str_pad()

 library(stringr)
 stringr::str_pad(0:9999, width = 4, side = "left", pad = "0")

  [1] "0000" "0001" "0002" "0003" "0004" "0005" "0006" "0007" "0008" "0009" ...
  •  Tags:  
  • r
  • Related