I am trying to create a sequence of months from Jan- Dec 3 times. ie. Jan Feb Mar . . . . Dec Jan Feb Mar . . . . Dec Jan Feb Mar . . . . Dec
I tried this code
rep(c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"),each=3)
but it generates result like this
[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"
but I want Jan Feb Mar....Dec Jan Feb Mar.....Dec Jan Feb Mar...Dec
Thanks Harshad
We can use month.abb
instead of c('Jan', 'Feb')
, etc..
rep(month.abb, 3)
For full month name
rep(month.name, 3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With