[R] How to obtain a sequence of dates consisting of only weekdays

Yihui Xie xieyihui at gmail.com
Thu Sep 11 11:02:28 CEST 2008


draw a subset of your data using a logical vector like this:

# for 50 weeks
rep(c(rep(TRUE, 5), rep(FALSE, 2)), 50)

Yihui

On Thu, Sep 11, 2008 at 4:31 PM, Weiyang Lim <Weiyang.Lim at henderson.com> wrote:
> Dear R-users,
>
> How do I obtain a sequence of dates consisting of only weekdays without the weekends in R?
>
> In S, I can do the following:
>
> timeSeq(from="12/17/2007", to="8/25/2008", by="weekdays")
>
> I tried using looking at timeSequence (fSeries package) and seq.Date (base package) but I do not know if I can specify "weekdays" rather than "day".
>
> Hope to have some assistance.
>
> Thank you!
>
> Regards,
> wy


-- 
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



More information about the R-help mailing list