Try this:

rowsum(Income, format(Date, '%m-%Y'))

or

tapply(Income, format(Date, '%m-%Y'), sum)

On Wed, Sep 9, 2009 at 7:51 AM, clair.crossup...@googlemail.com <
clair.crossup...@googlemail.com> wrote:

> Dear all,
>
> Lets say I have a data frame as follows:
>
>
> > Date <- as.Date(c('2006-08-23', '2006-08-30', '2006-09-06', '2006-09-13',
> '2006-09-20'))
> > Income <- c(73.79, 72.46, 76.32, 72.43, 72.62)
> > data.frame(Date, Income)
>        Date Income
> 1 2006-08-23  73.79
> 2 2006-08-30  72.46
> 3 2006-09-06  76.32
> 4 2006-09-13  72.43
> 5 2006-09-20  72.62
> >
>
> is there a way to group the data by month (summing the values in each
> month), i.e.
>
> Date       Income
> 2006-08  146.25
> 2006-09  221.37
>
> Thanks in advance,
> C.C.
>
> ______________________________________________
> R-help@r-project.org 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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