Hi,

Perhaps you can try:

> df
         Date Amount
1  2007-06-01      1
2  2007-06-01      1
3  2007-06-04      2
4  2007-06-05      2
5  2007-06-11      3
6  2007-06-12      3
7  2007-06-12      3
8  2007-06-13      3
9  2007-06-13      3
10 2007-06-18      4
11 2007-06-18      4
12 2007-06-25      5
13 2007-06-28      5

df_ok <- aggregate(df$Amount, by=list(df$Amount), FUN=sum)
levels(df_ok$Group.1)<- paste("2007/06/Week", 1:5, sep="")
-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

On 23/07/07, Jacques Wagnor <[EMAIL PROTECTED]> wrote:
>
> 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)
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to