Reputation: 33
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
Upvotes: 3
Views: 1549
Reputation: 25444
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.
Upvotes: 8