简体   繁体   中英

How to create a sequence starting with a character and then with numbers in R

How to create a sequence starting with a character and then with numbers in R

I wanna to create a sequence like the following: y1998 y1999 y2000 till y2011

There's : :

1998:2011

And ' or " to create string constants:

'y'

And paste0 to concatenate both:

paste0('y', 1998:2011)

Note how the paste0 function is applied to the second parameter, element by element. That's one of R's strengths.

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