gpt4 book ai didi

r - 如何创建特定月份和/或日期序列 "n"次

转载 作者:行者123 更新时间:2023-12-02 03:15:03 27 4
gpt4 key购买 nike

我正在尝试创建一系列月份1月至12月共3次。 IE。扬二月三月。。。。十二月扬二月三月。。。。十二月扬二月三月。。。。十二月

我尝试了这段代码

rep(c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"),each=3)

但它会生成这样的结果

[1] "Jan"  "Jan"  "Jan"  "Feb"  "Feb"  "Feb"  "Mar"  "Mar"  "Mar"  "Apr"  "Apr"  "Apr" 
[13] "May" "May" "May" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug"
[25] "Sept" "Sept" "Sept" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec"

但我想要一月二月三月...十二月一月二月三月...十二月一月二月三月...十二月

谢谢哈沙德

最佳答案

我们可以使用month.abb代替c('Jan', 'Feb')等。

 rep(month.abb, 3)

完整月份名称

 rep(month.name, 3)

关于r - 如何创建特定月份和/或日期序列 "n"次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33435755/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com