[R] Summing daily data for each year

Santosh.Aryal at csiro.au Santosh.Aryal at csiro.au
Wed Mar 17 07:20:14 CET 2010


Hello there 
  
I have a DAILY data set (as shown below) with Date and 
 Streamflow from April 1995 to Aug 2006.  I want a yearly sum 
the streamflow value (for each year - first and last 
incomplete year).  

Does anyone know how to do this in R?
 
I have tried everything I could think of, e.g. imported the 
streamflow data as time series using:
 
flowdata <- ts(ZVo[,2],start = c(1995,4,1), frequency = 7) # 
perhaps frequency = 365 is the better one and tried to 
aggregate using aggregate() without success

>ZVo
             V1      V2
 1  1995-04-01 0.002766309
 2  1995-04-02 0.002402973
 3  1995-04-03 0.002254335
 4  1995-04-04 0.002221305
 5  1995-04-05 0.002180017
 6  1995-04-06 0.002031379
 7  1995-04-07 0.001957060
 8  1995-04-08 0.001940545
 9  1995-04-09 0.001924030
 10 1995-04-10 0.001783650
 .
 .
 .
 4156 2006-08-16 0.02861272
 4157 2006-08-17 0.03652353
 4158 2006-08-18 0.05372419
 4159 2006-08-19 0.05630058
 4160 2006-08-20 0.06274154
 4161 2006-08-21 0.06981833
 
 Many thanks 
 
 Santosh 
 


More information about the R-help mailing list