[R] for loop if else conditional
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Oct 15 16:44:54 CEST 2007
See ?seq.Date, e.g.
now <- Sys.Date()
dd <- seq(now - 20, now, by = "day")
dd[as.POSIXlt(dd)$wday %% 6 != 0]
and have a look at R News 4/1.
On 10/15/07, Vishal Belsare <shoot.spam at gmail.com> wrote:
> date <- as.POSIXlt(Sys.time()) #present date
> for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
> if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
> (date-86400))} else (assign("date", (date-86400)))
>
>
> I am trying to print dates from present day to a day in the past, but
> omitting weekends. I am not doing something right, but can't figure
> out what. Help appreciated!
>
>
> Vishal Belsare
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list