SriniShine
SriniShine

Reputation: 1139

R: Creating an alphanumeric sequence with fixed length numbers

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

Upvotes: 0

Views: 1598

Answers (1)

akrun
akrun

Reputation: 887118

We can use sprintf

sprintf("M_%03d", 1:100)

Upvotes: 2

Related Questions