[R] How to generate a sequence of dates without hardcoding the year

Felipe Carrillo mazatlanmexico at yahoo.com
Sat Jul 24 23:07:25 CEST 2010


Hi:
I have a dataframe named 'spring' and I am trying to add a new variable named 
'IdDate'
This line of code works fine:
spring$idDate <- seq(as.Date("2008-07-01"),as.Date("2009-06-30"),by="week")

But I don't want to hardcode the year because it will be used again the 
following year
Is it possible to just generate dates with the month and day? 

I tried the code below:
seq(as.Date("7-1","%B%d"),as.Date("6-30","%B%d"),by="week")

and got this error message:
Error in seq.int(0, to - from, by) : 'to' must be finite
Thanks for any pointers

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA






More information about the R-help mailing list