[R] Question on "Zoo" object

Gabor Grothendieck ggrothendieck at gmail.com
Wed Feb 24 14:37:40 CET 2010


Try this:

> aggregate(daily.dat, format(time(daily.dat), "%m"), sd)
       01        02        03        04        05        06        07        08
0.9473855 0.8577099 1.0614892 1.0120308 1.1301652 1.0969453 1.0327717 1.0392682
       09        10        11        12
1.0276672 1.0173960 0.8953093 1.0964024

On Wed, Feb 24, 2010 at 8:31 AM, Bogaso <bogaso.christofer at gmail.com> wrote:
>
> Thanks Gabor for this reply. Your first reply answers my question, however
> end is not. Here you said :
>
>> set.seed(1)
>> daily.dat <- zooreg(rnorm(500), start=as.Date("2000-01-01"), frequency=1)
>> aggregate(daily.dat, as.yearmon, sd)
>  Jan 2000  Feb 2000  Mar 2000  Apr 2000  May 2000  Jun 2000  Jul 2000  Aug
> 2000
> 0.9370553 0.7743405 0.9514569 0.8813805 0.9188229 1.0969453 1.0327717
> 1.0392682
>  Sep 2000  Oct 2000  Nov 2000  Dec 2000  Jan 2001  Feb 2001  Mar 2001  Apr
> 2001
> 1.0276672 1.0173960 0.8953093 1.0964024 0.9696928 0.9507952 1.1275021
> 1.1410237
>  May 2001
> 1.5286202
>
> But what I want is, to aggregate "all" data on a particular month for all
> years and apply statistics on that aggregated data. Therefore I should get
> only 12 values (for 12 months) not 17 values. Is there any way to do that?
>
> Thanks,
> --
> View this message in context: http://n4.nabble.com/Question-on-Zoo-object-tp1567207p1567464.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