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
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
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
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. >
Apparently Analagous Threads
- String concatenation, File Path Handling to pass to download.file( ) [backslash in DOS paths]
- try / tryCatch for download.file( ) within a for loop when URL does not exist
- diff in a dataframe
- changing the day of the week in dates format
- RODBC / odbcConnectExcel Issue