as.yearqtr () from the package zoo appears to use the start of the quarter:
zoo
library(zoo) x <- "2015-05-17" x <- as.Date(x) x <- as.Date(as.yearqtr(x)) x # [1] "2015-04-01"
How can I grab the end of the block instead?
x # [1] "2015-06-30"
Thank!
Use frac = 1 as shown:
frac = 1
x <- as.Date("2015-05-17") as.Date( as.yearqtr(x), frac = 1 )
giving:
[1] "2015-06-30"
library(zoo) x <- as.Date("2015-05-17") x <- as.Date(as.yearqtr(x)+0.25)-1 x # [1] "2015-06-30"
as.yearqtr(x)+0.25 gives you the next quarter. as.Date gives you the first day of the next quarter. -1 returns the last day of the original quarter.
as.yearqtr(x)+0.25
as.Date
-1