Hi, I have a question below:
Create a sequence of class Date that starts from September 1, 2020 and ends on September 30, has all the days, but omits weekend days.
I have all days in September 2020, but do not know how to remove weekends. I just start learning R, can anyone explain how to get that part? Thank you.
dts = seq(as.Date("2000-09-01"),
by = "day",
length.out = 30,
)
The lubridate package has a handy function for this.
By default Saturday is the 6th day of the week, so:
dts[lubridate::wday(dts) < 6]
Edit
Hmm, just double checked this. It seems I remembered wrong - that's what I get for not coding it first! The default first day of the week is actually Sunday (see ?wday), so try this instead