Reputation: 10568
I know that I can call:
library(zoo)
Sys.Date()
CQ <- as.yearqtr(Sys.Date())
CQ
And get:
"2015-03-05"
"2015 Q1"
But I need my output to be:
"Q1-2015"
How can I convert CQ to be QX-YYYY?
Upvotes: 1
Views: 291
Reputation: 92300
You can achieve a similar result using the base R. For example,
x <- seq(Sys.Date(), Sys.Date() + 180L, by = "month") # Generate some dates vector
paste(quarters(x), as.POSIXlt(x)$year + 1900L, sep = "-")
## [1] "Q1-2015" "Q2-2015" "Q2-2015" "Q2-2015" "Q3-2015" "Q3-2015"
Upvotes: 1