# rep(x, …):將vector x的值循環n遍
rep(1:4, 2)
[1] 1 2 3 4 1 2 3 4
# times:整個數組循環幾遍
rep(1:4, each = 2, times = 3)
[1] 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4
# each:每個element循環幾遍
rep(1:4, each = 2)
[1] 1 1 2 2 3 3 4 4
rep(1:4, c(2,2,2,2))
[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.out 輸出長度為多少
rep(1:4, each = 2, len = 4)
[1] 1 1 2 2 #長了會被截掉
rep(1:4, each = 2, len = 13)
[1] 1 1 2 2 3 3 4 4 1 1 2 2 3 #短了會根據前面規則補上