Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0812121103w60458d7cxf01b9a422d0620ad@mail.gmail.com>
Date: 2008-12-12T19:03:25Z
From: Gabor Grothendieck
Subject: loop with dates
In-Reply-To: <3805f3080812121055j36ca0304n6f4940c8e606a748@mail.gmail.com>

Try iterating over the index rather than the value of
each component:

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:
> Hello,
>
> 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)[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
> 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.
>