[R] loop with dates
ggrothendieck at gmail.com
Fri Dec 12 20:03:25 CET 2008
Try iterating over the index rather than the value of
s <- seq(fini,to = ffin, by='days')
for (i in seq_along(s)) print(s[[i]])
On Fri, Dec 12, 2008 at 1:55 PM, Fernando Bizuet <fbizuet at gmail.com> wrote:
> I am trying to do a loop with dates, but when I try to use the index is not
> a date.
> Fcorte <- as.Date('2008/11/30',format = "%Y/%m/%d")
> fini <- Fcorte + 1
> ffin <- seq(fini,by='months',length=2) - 1
> for (i in seq(fini,to = ffin, by='days'))
> print (weekdays(i)) # i doesn't a date
> How can I do a loop with dates and get the index of each date? are there a
> method to convert the index i to date?
> Thanks in advance.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help