[R] extract certain months toyears (zoo)
Bastian Pöschl
rotate at gmx.li
Fri Jan 23 12:52:00 CET 2009
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
More information about the R-help
mailing list