Skip to content
Prev 334489 / 398503 Next

why there is no quarters?

That will only work if your starting date happens to be the first day of the year:

x <- seq(as.Date("2001/1/1"), as.Date("2010/1/1"), "3 months")
[1] "2001-01-01" "2001-04-01" "2001-07-01" "2001-10-01" "2002-01-01"
[6] "2002-04-01"


Compare that to:

x2 <- seq(as.Date("2001/2/3"), as.Date("2010/1/1"), "3 months")
[1] "2001-02-03" "2001-05-03" "2001-08-03" "2001-11-03" "2002-02-03"
 [6] "2002-05-03" "2002-08-03" "2002-11-03" "2003-02-03" "2003-05-03"


The "3 months" is literally 3 months from the defined start date, not 3 months from the first of the year. So you are not going to get calendar quarter starting dates in that case.


On the other hand:
[1] 2001-01-01 2001-04-01 2001-07-01 2001-10-01 2002-01-01 2002-04-01
 [7] 2002-07-01 2002-10-01 2003-01-01 2003-04-01 2003-07-01 2003-10-01
[13] 2004-01-01 2004-04-01 2004-07-01 2004-10-01 2005-01-01 2005-04-01
[19] 2005-07-01 2005-10-01 2006-01-01 2006-04-01 2006-07-01 2006-10-01
[25] 2007-01-01 2007-04-01 2007-07-01 2007-10-01 2008-01-01 2008-04-01
[31] 2008-07-01 2008-10-01 2009-01-01 2009-04-01 2009-07-01 2009-10-01
36 Levels: 2001-01-01 2001-04-01 2001-07-01 2001-10-01 ... 2009-10-01


Regards,

Marc Schwartz
On Dec 16, 2013, at 6:35 AM, D?niel Kehl <kehld at ktk.pte.hu> wrote: