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

Cren oscar.soppelsa at bancaakros.it
Tue May 15 18:42:03 CEST 2012


Thank you for your help, Michael.

I used *aggregate(x, by = timeSequence(by = "day"), FUN = sum)* but the
results is very different from *sum(x[1:13])*, where 13 is the number of
daily observations I've sampled.

Michael Weylandt wrote
> 
> 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@> 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@ 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.
> 
> ______________________________________________
> R-help@ 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.
> 


--
View this message in context: http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630139.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list