I need to take a vector of dates and for each date get the first day of the next quarter.
(Or rather, to round to the last day of the current quarter, find the first
The zoo
package can help for many things date-related including this:
library(zoo)
as.yearqtr("2014-08-15", format="%Y-%m-%d")
## [1] "2014 Q3"
as.Date(as.yearqtr("2014-08-15", format="%Y-%m-%d"))
## [1] "2014-07-01"
But, that might not get you what you need (there are ways to extrapolate from those values).
The timeDate
package has:
timeFirstDayInQuarter(charvec, format = "%Y-%m-%d", zone = "", FinCenter = "")
timeLastDayInQuarter(charvec, format = "%Y-%m-%d", zone = "", FinCenter = "")
which might make it easer to use and tweak to adjust for different Q1 start origins.