Re: [R] Help with date specification

2009-09-17 Thread Mark Knecht
On Thu, Sep 17, 2009 at 9:11 AM, Subodh Acharya wrote: > Hi everyone,I have a data daily data (x) for 10 years starting from > 04-01-1995 to 03-31-2005. > I was able to get the yearly sum for the ten years using > aggregate(x, years, sum). > But this gave me the yearly sum for 1995 (Apr- Dec); 199

Re: [R] Help with date specification

2009-09-17 Thread Gabor Grothendieck
Try either of these which convert to year and qtr and then shift the qtr by one. The resulting series is labeled by the year in which the series dates start. Use as.integer(...) + 1 if you prefer to label by ending year. library(zoo) # test data DF <- data.frame(date = Sys.Date() + 1:1000, value

Re: [R] Help with date specification

2009-09-17 Thread Schalk Heunis
Subodh Assuming the data is ordered by date then you can define fin.years = (0:(10*12-1)) %/% 12 then use aggregate: aggregate(x, list(fin.years),sum) HTH Schalk Heunis On Thu, Sep 17, 2009 at 6:11 PM, Subodh Acharya wrote: > Hi everyone,I have a data daily data (x) for 10 years starting from

[R] Help with date specification

2009-09-17 Thread Subodh Acharya
Hi everyone,I have a data daily data (x) for 10 years starting from 04-01-1995 to 03-31-2005. I was able to get the yearly sum for the ten years using aggregate(x, years, sum). But this gave me the yearly sum for 1995 (Apr- Dec); 1996 (Jan-Dec) -2005 (Jan-Mar). But I want to get the aggrega