Skip to content
Back to formatted view

Raw Message

Message-ID: <1232711520.5927.0.camel@bleiche>
Date: 2009-01-23T11:52:00Z
From: Bastian Pöschl
Subject: extract certain months toyears (zoo)

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