As in this example:> seq(as.Date("2000/1/1"), as.Date("2003/1/1"), by="mon")On 7/12/10 11:25 AM, "Bogaso Christofer" <bogaso.christofer at 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") > > Error in del/by : non-numeric argument to binary operator > > > > What is the correct way to do that? > > > > Thanks for your time. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory 925 423-1062
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")Error in del/by : non-numeric argument to binary operator What is the correct way to do that? Thanks for your time. [[alternative HTML version deleted]]
Am 12.07.2010 20:25, schrieb Bogaso Christofer:>> library(zoo) > >> seq(as.yearmon("2010-01-01"), as.yearmon("2010-03-01"), by="1 month") >seq(as.Date("2010-01-01"), as.Date("2010-03-01"), by="1 month") hth Stefan
On Mon, Jul 12, 2010 at 2:25 PM, Bogaso Christofer <bogaso.christofer at 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.