Hi: On Wed, Aug 18, 2010 at 4:43 PM, skan <juanp...@gmail.com> wrote:
> > Hi > > > Usually "aggregate" is used to calculate things such as the sum of all data > on the first day, the sum next day, and so on. > But how can I calculate the mean of the first hour of all days, the mean of > the second hour of all days, and so on. ??? > > That's > Most examples: > today at 1am + today at 2am + today at 3am +.... -> sum > today > tomorrow at 1am + tomorrow at 2am + tomorrow at 3am +.... -> sum > tomorrow > .................. > aggregate(data, as.Date,sum) > > > But what I need is: > data today at 1 + data tomorrow at 1 + data in two days at 1 + ..... -> > sum at 1am > data today at 2 + data tomorrow at 2 + data in two days at 2 + ..... -> > sum at 2am > data today at 3 + data tomorrow at 3 + data in two days at 3 + ..... -> > sum at 3am > ............. > > How can I do it?? > Aggregate by day/hour combinations, put the results in a matrix with days as rows and hours as columns, and then use colSums(), perhaps? HTH, Dennis > > cheers > -- > View this message in context: > http://r.789695.n4.nabble.com/Different-way-of-aggregating-tp2330497p2330497.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > [[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.