[R] Annual cumulative sums from time series

Georg Hoermann georg.hoermann at gmx.de
Thu Feb 10 11:01:11 CET 2005


Hello world,

I am actually transferring a course in data management for
students in biology, geography and agriculture 
from statistica to R - it works
surprisingly well. If anyone is interested in my scratch/notepad
(in German language), please see

www.hydrology.uni-kiel.de/~schorsch/statistik/statistik_datenauswertung.pdf

(pages 40-52)

The dataset is:

www.hydrology.uni-kiel.de/~schorsch/statistik/erle_stat.csv

It contains a 10 year dataset. So far for introduction, now
comes the problem:

we often need cumulative *annual* sums (sunshine, precipitation),
 i.e. the sum
must reset to 0 at the beginning of the year. I know
of cumsum(), but I do not now how to split the dataset automagically 
into annual pieces so I can cumsum() every year separately.
I have the strong hope that the solution is one of these
one-liners which leave the students with eyes wide open in surprise and 
makes them true believers in the power of the command-line 8-).

Thanks & Greetings
Georg


-- 
Georg Hoermann, Luebeck, Germany
Tel. 0451/47 70 32, 0172/431 57 15, Penguin #189476




More information about the R-help mailing list