[R] for loop if else conditional

Vishal Belsare shoot.spam at gmail.com
Mon Oct 15 16:27:08 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


-- 
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects."
~ Robert Heinlein



More information about the R-help mailing list