0

I want to create a list of 4 digits of numbers ranging from 0 to 9999 as per the ezample bellow:

list(c("0001","0002","0003","...","9998","9999"))     

Nikos Hidalgo
  • 3,666
  • 9
  • 25
  • 39
Lucas
  • 549
  • 1
  • 4
  • 16

1 Answers1

0

You can use formatC,

formatC(1:999, width=4, flag = "0")

or sprintf("%04d", 1:9999) mentioned by GKi

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Mingze Li
  • 1
  • 3