[R] for loop if else conditional

Vishal Belsare shoot.spam at gmail.com
Mon Oct 15 16:08:15 CEST 2007


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



More information about the R-help mailing list