Please read the last line to every post on r-help particularly
noting the reproducible part.
Assuming you have a series such as z below and want
June, July and August of each year:
> library(zoo)
> set.seed(1)
> z <- zoo(rnorm(25), as.yearmon("2000-01") + 0:24/12)
> z[format(time(z), "%m") %in% c("06", "07",
"08")]
Jun 2000 Jul 2000 Aug 2000 Jun 2001 Jul 2001 Aug 2001
-0.8204684 0.4874291 0.7383247 0.9438362 0.8212212 0.5939013
On Fri, Jan 23, 2009 at 6:52 AM, Bastian P?schl <rotate at gmx.li>
wrote:> Dear useRs and developeRs,
> In my diploma thesis I work with a daily time series of glacier runoff
> data.
> I did already aggregate them to monthly means etc.
> Now i want to use just the summer values (I am indecisive by now what
> that means, but let's make it easy and use months like June).
> Is there a way to extract the data off this zoo into another zoo with
> frequency=1 ?
>
> Do you have alternative suggestions how to get to such data??
>
>
> what i did...
>
> #########################################################
> ## want to create monthly aggr. and extract the summer data
> #########################################################
> library(zoo)
> a.z<- read.zoo("glacierdischarge.txt", header=TRUE,
sep=",", dec = ".",
> na.string="NA", format = "%d.%m.%Y")
> a.z.mean <- aggregate(a.z, as.yearmon, mean)
> a.z.median <- aggregate(a.z, as.yearmon, median)
> a.z.sd <- aggregate(a.z, as.yearmon, sd)
> a.z.min <- aggregate(a.z, as.yearmon, min)
> a.z.max <- aggregate(a.z, as.yearmon, max)
> a.z.sum <- aggregate(a.z, as yearmon, sum)
> a.zoo<-cbind(mean = a.z.mean, median= a.z.median, sd = a.z.sd, min>
a.z.min, max= a.z.max)
> head(a.zoo)
>
>
> I tried it with merge and...
>
> ##vector including all junes
> l<-length(a.zoo$mean)
> Junes<-seq(6, l, by = 12)
>
> but stuck.
>
> Hopefully
>
> Bastian
>
> ______________________________________________
> 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.
>