0

I need to create an alphanumeric sequence as follows. The following code creates the sequence as M_1, M_2, ... etc

paste0("M_",seq(1:100))

I need all the numbers to appear as 3 digit numbers. i.e. M_001, M_002 etc

SriniShine
  • 1,089
  • 5
  • 26
  • 46
  • Possible duplicate of [Format number as fixed width, with leading zeros](http://stackoverflow.com/questions/8266915/format-number-as-fixed-width-with-leading-zeros) – Ronak Shah Apr 01 '17 at 16:03
  • Possible duplicate of [Adding leading zeros using R](http://stackoverflow.com/questions/5812493/adding-leading-zeros-using-r) – Uwe Apr 02 '17 at 05:35

1 Answers1

2

We can use sprintf

sprintf("M_%03d", 1:100)
akrun
  • 874,273
  • 37
  • 540
  • 662