[英]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 如何在R中创建以字符开头然后以数字开头的序列
I wanna to create a sequence like the following: y1998 y1999 y2000 till y2011 我想创建如下序列:y1998 y1999 y2000到y2011
There's :
: 有
:
:
1998:2011
And '
or "
to create string constants: 和
'
或"
创建字符串常量:
'y'
And paste0
to concatenate both: 和
paste0
连接这两个:
paste0('y', 1998:2011)
Note how the paste0
function is applied to the second parameter, element by element. 请注意如何将
paste0
函数逐个元素应用于第二个参数。 That's one of R's strengths. 这是R的优势之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.