On Mon, Jul 12, 2010 at 2:25 PM, Bogaso Christofer <bogaso.christo...@gmail.com> wrote: > Hi all, can anyone please guide me how to create a sequence of months? Here > I have tried following however couldn't get success > >> library(zoo) > >> seq(as.yearmon("2010-01-01"), as.yearmon("2010-03-01"), by="1 month") >
There currently is no seq method (we will make a note to add one) for yearmon but you can add the appropriate sequence to the starting yearmon object, use zooreg or convert to numeric or Date, perform the seq and then convert back # yearmon + seq as.yearmon("2010-01-01") + 0:2/12 as.yearmon("2010-01") + 0:2/12 # zooreg time(zooreg(1:3, as.yearmon("2010-01"), freq = 12)) # seq.default as.yearmon(seq(as.numeric(as.yearmon("2010-01")), as.numeric(as.yearmon("2010-03")), 1/12)) # seq.Date as.yearmon(seq(as.Date("2010-01-01"), as.Date("2010-03-01"), by = "month")) Also note that if the reason you are doing this is to create a zooreg object then its not necessary to explicitly form the sequence in the first place since zooreg only requires the starting time and a frequency as shown above. ______________________________________________ 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.