Thanks Dr. Gabor, the commands you gave worked. ---------------------------- ZABLONE OWITI GRADUATE STUDENT College of Atmospheric Science Nanjing University of Information, Science and Technology Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China Tel: +86-25-58731402 Fax: +86-25-58731456 Mob. 15077895632 Website: www.nuist.edu.cn ====================================================
---------------------------------------- From: "Gabor Grothendieck" <ggrothendi...@gmail.com> Sent: Wednesday, May 12, 2010 7:15 PM To: zow...@ncst.go.ke Subject: Re: [R] How to extract sum of particular months in a monthly data series 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 posted some sample data. On Tue, May 11, 2010 at 11:10 PM, Zablone Owiti wrote: > 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. My > attempt to aggregate with the zoo package using the function as.yearqtr > failed since this sums evey three months of the year from January. Is there > away it can be coersed to aggregate particular months as in my case? > > Thanks > > ---------------------------- > ZABLONE OWITI > GRADUATE STUDENT > College of Atmospheric Science > Nanjing University of Information, Science and Technology > Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China > Tel: +86-25-58731402 > Fax: +86-25-58731456 > Mob. 15077895632 > Website: www.nuist.edu.cn > ==================================================== > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.