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,388
  • 9
  • 23
  • 35
Lucas
  • 499
  • 3
  • 13

1 Answers1

0

You can use formatC,

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

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

Suraj Rao
  • 28,850
  • 10
  • 94
  • 99
Mingze Li
  • 1
  • 3