如何在R中以不同的方式复制向量中的字符串?

如何在R中以不同的方式复制向量中的字符串?,r,repeat,replicate,R,Repeat,Replicate,我有这个向量: Photoperiod <- c("Day","Sunset","Night","Sunrise") Photoperiod关于: rep(rep(c("Day","Sunset","Night","Sunrise"), c(12, 2, 8, 2)), length.out = 168) 另一个选择是使用一个r

我有这个向量:

Photoperiod <- c("Day","Sunset","Night","Sunrise")
Photoperiod关于:

rep(rep(c("Day","Sunset","Night","Sunrise"), c(12, 2, 8, 2)), length.out = 168)

另一个选择是使用一个
rep
和回收技术

x <- character(168)
x[] <- rep(Photoperiod, c(12, 2, 8, 2))
x