我想重复一个因素,如下图所示:我不确定是否可以使用rep()
函数完成此操作?
输入:
c("100G","105G","302G")
出:
c("100G","100G","100G","100G","100G","105G","105G","105G","105G","105G","302G","302G","302G","302G","302G")
答案 0 :(得分:2)
是的,这可以做到......
这应该可以解决问题:
rep(c("100G","105G","302G"), each=10)
答案 1 :(得分:1)
可以这样做:
inputVec <- c("100G","105G","302G")
outputVec <- rep(inputVec, each = 5)
outputVec