[R] How to sum and group data by DATE in data frame

R. Michael Weylandt michael.weylandt at gmail.com
Tue May 15 18:14:14 CEST 2012


How are you using aggregate()? It seems to sum for me...

z <- zoo(1:50, seq.POSIXt(from = Sys.time(), by = "30 min", length.out = 50))

aggregate(z, as.Date(time(z)), sum)

Best,
Michael

On Tue, May 15, 2012 at 11:52 AM, Cren <oscar.soppelsa at bancaakros.it> wrote:
> Hello,
>
> I have a time series with intraday datas, sampled every 30'; I would need to
> aggregate them in this way: summing up all datas within a day.
>
> I tried to use *aggregate(...)* function to get my goal, but it aggregates
> in wrong way (I did not understand how so far); what I need is like
> *sum(...)* function applied to datas within the same day.
>
> Thank you :)
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630119.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list