[R] Aggregate daily data into weekly sums

Jacques Wagnor jacques.wagnor at gmail.com
Mon Jul 23 21:18:44 CEST 2007


Dear Lest,

I have a two-variable data frame as follows (the time peirod of the
actual data set is 10 years):

        Date Amount
1   6/1/2007      1
2   6/1/2007      1
3   6/4/2007      2
4   6/5/2007      2
5  6/11/2007      3
6  6/12/2007      3
7  6/12/2007      3
8  6/13/2007      3
9  6/13/2007      3
10 6/18/2007      4
11 6/18/2007      4
12 6/25/2007      5
13 6/28/2007      5


Basically, I would like to collapse the daily data into weekly sums
such that the result should look like the following:

              Date Amount
1  2007/6/Week1       2
2  2007/6/Week2       4
3  2007/6/Week3       15
4  2007/6/Week4       8
5  2007/6/Week5      10

Does there already exist a function that aggregates the data at
user-defined time frequency?

Any pointers would be greatly appreciated.

Jacques

> version
               _
platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
status
major          2
minor          5.0
year           2007
month          04
day            23
svn rev        41293
language       R
version.string R version 2.5.0 (2007-04-23)



More information about the R-help mailing list