September 2008 20:09
To: Weiyang Lim
Cc: r-help@r-project.org
Subject: Re: [R] How to obtain a sequence of dates consisting of only weekdays
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
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 the
In fact, you can even use weekdays() to get the names of the weekdays
and then use the operator "%in%" to exclude the weekends. In this
case, I'm sure there will be no further problems :-)
Yihui
On Thu, Sep 11, 2008 at 5:33 PM, Weiyang Lim <[EMAIL PROTECTED]> wrote:
> I see. That's a nice idea. T
Then you can use c() to add the indices of those weeks which are not
"complete", or use something like this
# from Tuesday to next Wedsday
> !(2:10 %% 7) %in% c(0,6)
[1] TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
Yihui
On Thu, Sep 11, 2008 at 5:08 PM, Weiyang Lim <[EMAIL PROTECTED]> w
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 <[EMAIL PROTECTED]> wrote:
> Dear R-users,
>
> How do I obtain a sequence of dates consisting of only weekdays without the
> wee
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 kno
6 matches
Mail list logo