Now that I'm back at my computer, I'll actually suggest you do something
else entirely.

If you look at the code of holidayNYSE() or by calling listHolidays() of the
timeDate package you'll see that there are many many functions that get
every conceivable holiday directly. I'll let you pick the holidays you want,
but a simple script might be like this:

x<-seq(as.Date("2011-01-01"), as.Date("2011-12-31"),by="day")

GetHolidays <- function(x) {
    years = as.POSIXlt(x)$year+1900
    years = unique(years)
    holidays <- NULL
    for (y in years) {
#If you don't need the if/then statements to include which years something
was a NYSE holiday, you should drop the loop since the holiday functions are
vectorized
        if (y >= 1885)
            holidays <- c(holidays, as.character(USNewYearsDay(y)))
        if (y >= 1885)
            holidays <- c(holidays, as.character(USIndependenceDay(y)))
        if (y >= 1885)
            holidays <- c(holidays, as.character(USThanksgivingDay(y)))
        if (y >= 1885)
            holidays <- c(holidays, as.character(USChristmasDay(y)))
     }
     holidays = as.Date(holidays,format="%Y-%m-%d")
     ans = x %in% holidays
    return(ans)
}

This should return a boolean vector indicating which dates fall on the
selected holidays: feel free to add/delete holidays as you wish. To get the
actual holiday dates, this should work: x[GetHolidays(x)]. If you want to
identify things by holiday, you'll only have to modify the script slightly.
Let me know if I can help further!

Michael Weylandt

On Mon, Aug 1, 2011 at 4:57 PM, Dimitri Liakhovitski <
dimitri.liakhovitski@gmail.com> wrote:

> To be specific, I only need to get rid of 2 NYSE holidays:
> Washington's Birthday and Good Friday.
> Is there a way to reduce the vector of NYSE holidays in timeDate by
> throwing out those two?
> Thank you!
> Dimitri
>
> On Mon, Aug 1, 2011 at 4:24 PM, R. Michael Weylandt
> <michael.weylandt@gmail.com> <michael.weylandt@gmail.com> wrote:
> > Don't know if this is sufficiently slick for this list (which never fails
> to impress me with quick and elegant solutions) but I would point out to you
> that GF is the only NYSE holiday falling in March or April so it shouldn't
> be hard to discard it if desired.
> >
> > Michael Weylandt
> >
> > On Aug 1, 2011, at 4:18 PM, Dimitri Liakhovitski <
> dimitri.liakhovitski@gmail.com> wrote:
> >
> >> Just to clarify - I realize that "major" is subjective here. Maybe I
> >> should say "most common".
> >> But maybe there is a way for me to select from a list of all NYSE
> >> holidays and flag only some of them?
> >> Just not sure how to do it...
> >> Thanks!
> >> Dimitri
> >>
> >> On Mon, Aug 1, 2011 at 3:45 PM, Dimitri Liakhovitski
> >> <dimitri.liakhovitski@gmail.com> wrote:
> >>> Hello!
> >>>
> >>> I am trying to identify which ones of a vector of dates are US
> >>> holidays. And, ideally, which is which. And I do not know (a-priori)
> >>> which dates those should be.
> >>> I have, for example:
> >>>  x<-seq(as.Date("2011-01-01"),as.Date("2011-12-31"),by="day")
> >>> (x)
> >>>
> >>> I think chron should help me here - but maybe I am not using it
> properly:
> >>>
> >>> library(chron)
> >>> is.holiday(chron) # Says that none of those dates are holidays
> >>>
> >>> ?is.holiday says: "holidays" is an object that should be listing
> >>> holidays. But I want to figure out which of my dates are US holidays
> >>> and don't want to provide a list of
> >>>
> >>> Package timeDate does almost what I need:
> >>> library(timeDate)
> >>> holidayNYSE(2008:2010)
> >>> holidayNYSE()
> >>>
> >>> However, I don't need all the NYSE holidays (like Good Friday). Just
> >>> the major US holidays - New Years, MLK, Memorial Day, Independence
> >>> Day, Labor Day, Halloween, Thanksgiving, Christmas.
> >>> Is there any way to identify major US holidays?
> >>>
> >>> Thanks a lot!
> >>>
> >>> -
> >>> Dimitri Liakhovitski
> >>> marketfusionanalytics.com
> >>>
> >>
> >>
> >>
> >> --
> >> Dimitri Liakhovitski
> >> marketfusionanalytics.com
> >>
> >> ______________________________________________
> >> R-help@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.
> >
>
>
>
> --
> Dimitri Liakhovitski
> marketfusionanalytics.com
>

	[[alternative HTML version deleted]]

