10
@csgillespie: chron provides the function is.weekend:
days = seq(as.Date("1990-01-01"), as.Date("1990-12-31"), by="1 day")
library(chron)
weekDays = days[!is.weekend(days)]
## let's check the result with the function weekdays
weekdays(weekDays)
Besides, you can get the same results without chron using format:
isWeekend <- function(x) {format(x, '%w') %in% c(0, 6)}
weekDays2 = days[!isWeekend(days)]
There is a base function called ?weekdays.
startDate = "1990-01-01"
endDate = "1990-12-31"
x <- seq(as.Date(startDate), to = as.Date(endDate), by="1 day")
x[!weekdays(x) %in% c("Sunday", "Saturday")]
But, since the actual names of the days will be locale-specific, be sure to set those correctly.
Note that weekdays is just a wrapper on format(x, "%A"). See ?strptime for the details on the format codes.