1、直接测试,R实现1至4各重复3次
result <- vector() ## 空向量 for (i in 1:4) { result <- c(result, rep(i, 3)) } result
2、可以直接实现
rep(1:4, each = 3)