rep()函数是什么意思?怎么用?
rep()
rep():replicate,重复的意思,用于设定重复的模式。
rep(x, times)
x
times
数字:
> rep(1,2) [1] 1 1
字符串:
> rep('a',2) [1] "a" "a"
向量:
> rep(c('a','b'),2) [1] "a" "b" "a" "b"
范围:
> rep(1:2,2) [1] 1 2 1 2
Content: