简体   繁体   中英

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. ie M_001, M_002 etc

我们可以使用sprintf

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM