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

Gabor Grothendieck ggrothendieck at gmail.com
Thu Sep 11 14:09:07 CEST 2008


See ?is.holiday in chron, e.g.

library(chron)
s <- seq(from = chron("12/17/2007"), to = chron("8/25/2008"))
s.weekday <- s[!is.holiday(s)]

As discussed there one can also optionally define a .Holidays vector
containing dates which will also be excluded.

It also works with any class for which there is an as.chron
method.   R News 4/1 discusses various date classes.

On Thu, Sep 11, 2008 at 4:31 AM, 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
>
> **********************************************************
>
> The information provided in this e-mail is confidential and is for the sole use of the recipient. It may not be disclosed, copied or distributed in any form without the express permission of Henderson Global Investors and to the extent that it is passed on, care must be taken to ensure that this is in a form which accurately reflects the information presented here.
>
> Whilst Henderson Global Investors believe that the information is correct at the date of this e-mail, no warranty or representation is given to this effect and no responsibility can be accepted by Henderson Global Investors to any end users for any action taken on the basis of this information.
>
> Henderson Global Investors is the name under which Henderson Global Investors Limited (registered no. 906355), Henderson Fund Management plc (registered no. 2607112), Henderson Investment Funds Limited (registered no. 2678531), Henderson Investment Management Limited (registered no. 1795354) Henderson Alternative Investment Advisor Limited (registered no. 962757) and Henderson Equity Partners Limited (registered no.2606646) (each incorporated and registered in England and Wales with registered office at 4 Broadgate, London EC2M 2DA and authorised and regulated by the Financial Services Authority) provide investment products and services.  Henderson Secretarial Services Limited (incorporated and registered in England and Wales, registered no. 1471624, registered office 4 Broadgate, London EC2M 2DA) is the name under which company secretarial services are provided. All these companies are wholly owned subsidiaries of Henderson Group plc (incorporated and registered in England !
>  and Wales, registered no. 2072534, registered office 4 Broadgate, London EC2M 2DA).
>
> We may record telephone calls or email for our mutual protection and to improve customer service.
>
> **********************************************************
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list