seq产生等差序列
有以下几个参数
from,to起始数字和结束数字
> seq(2,10) [1] 2 3 4 5 6 7 8 9 10
seq(from, to, by= ) #by指定步长
> seq(2,10,by=3) [1] 2 5 8
seq(from, to, length.out= ) #指定长度,length.out=length
> seq(0, 1, length= 11) [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
对一组向量则按下标产生序列
x<-c(11,22,33,44,55,66,77)
> seq(x)#以长度(下标)生成序列
[1] 1 2 3 4 5 6 7```
###rep产生重复序列
参数
rep.int(x, times)# x要重复的对象 times重复的次数
> rep(1:4, 2)
[1] 1 2 3 4 1 2 3 4`
rep_len(x, each=)# each单个循环重复,如果不传入each参数则连续循环
> rep(1:4, each = 2) # not the same.
[1] 1 1 2 2 3 3 4 4`
> rep(1:4, c(2,1,2,1))#可指定某个向量循环的次数
[1] 1 1 2 3 3 4`
length指定长度
> rep(1:4, each = 2, len = 4) # first 4 only.
[1] 1 1 2 2
> rep(1:4, each = 2, len = 10) # 8 integers plus two recycled 1's.
[1] 1 1 2 2 3 3 4 4 1 1`








暂无数据