产生一些有顺序的数据的函数seq(), rep(),sample()
1,seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)),
length.out = NULL, along.with = NULL, ...)
> seq(1,20,by=3)
[1] 1 4 7 10 13 16 19
rep(x, times)
>rep(c(1:5),2)
[1] 1 2 3 4 5 1 2 3 4 5
2,sample(x, size, replace = FALSE, prob = NULL)
sample.int(n, size = n, replace = FALSE, prob = NULL)
3,prob代表所要抽取元素的概率
>sample.int(c(1:10),size = 3,replace = T,prob = 0.8)
[1] 1 1 1
4,gl()产生带有因子的函数:gl(n, k, length = n*k, labels = seq_len(n), ordered = FALSE)
> gl(2,3)
[1] 1 1 1 2 2 2
Levels: 1 2
5,rnorm()产生服从标准正态分布的随机数 rt()服从t分布的随机数