[R] cum sums
Philip A. Viton
viton.1 at osu.edu
Sun Mar 9 19:57:42 CET 2014
Suppose I have a dataframe beginning:
id yr val
a 1950 1
b 1950 10
a 1951 2
I'm trying to produce a table of cumulative sums
of val, disaggregated by id and then yr, so the result
should begin
id yr cumval
a 1950 1
a 1951 3
b 1950 10
I've been trying to do this using "aggregate"
and passing the function "cumsum," but I can't get
it to work. Can someone tell me how to do this?
Thanks!
------------------------
Philip A. Viton
City Planning, Ohio State University
275 West Woodruff Avenue, Columbus OH 43210
viton.1 at osu.edu
More information about the R-help
mailing list