Skip to Content

summing based on daily maxima values

I'm trying to write an R script that will go through a dataframe that i import from an excel spreadsheet (see below for format), and find the sum of daily values until the daily maxima (and including the daily maxima)

The data looks something like this:

5/1/2012  0:00  0         
5/1/2012  3:00  1
5/1/2012  6:00  2
5/1/2012  9:00  5
5/1/2012 12:00  3
5/1/2012 15:00  6
5/1/2012 18:00  2
5/1/2012 21:00  1
5/2/2012  0:00  2
5/2/2012  3:00  3
5/2/2012  6:00  6
5/2/2012  9:00  4
5/2/2012 12:00  6
5/2/2012 15:00  7
5/2/2012 18:00  9
5/2/2012 21:00  1

So the function I'm envisioning would return:

1 5/1/2012 15:00 17
2 5/2/2012 18:00 35

Any ideas?