Re: [R] How to extract sum of particular months in a monthly data series

2010-05-12 Thread Zablone Owiti
-58731456 Mob. 15077895632 Website: www.nuist.edu.cn From: "Gabor Grothendieck" Sent: Wednesday, May 12, 2010 7:15 PM To: zow...@ncst.go.ke Subject: Re: [R] How to extract sum of particular m

Re: [R] How to extract sum of particular months in a monthly data series

2010-05-12 Thread Gabor Grothendieck
Try this: library(zoo) z <- as.zoo(AirPassengers) time(z) <- as.yearmon(time(z)) ix <- cycle(as.ts(z)) %in% c(3:5, 10:11) aggregate(z[ix], floor, sum) or this: ix <- format(time(z), "%m") %in% c("03", "04", "05", "10", "11") aggregate(z[ix], floor, sum) It would be best if next time you poste

[R] How to extract sum of particular months in a monthly data series

2010-05-11 Thread Zablone Owiti
Dear Users, I have a monthly data for a number of years(1960-2007) for a number of stations and i wish to extract sesonal time-series for the months of March-May and October-November for very station. I have read this data with read.table in R with stations as columns and time (months) as rows