How do I access the "right" holidays in timeDate

Searched, but could not find the answer to this question. Essentially, the timeDate package has some internal code that it didn’t disclose, and I am wondering how to do this:

> USDecorationMemorialDay(2013)

GMT
[1] [2013-05-30]

> holidayNYSE(2013)

NewYork
[1] [2013-01-01] [2013-01-21] [2013-02-18] [2013-03-29] [2013-05-27] [2013-07-04] [2013-09-02] [2013-11-28] [2013-12-25]

as you can see here, the USDecorationMemorialDay function is erroneous because Memorial Day is the last Monday of May. however, they somehow implemented a correction in the holidayNYSE function, so it gives [2013-05-27]. What's up with that?

The big picture. I really want to have a national holiday calendar by country. timeDate created the UK, USA, Switzerland and Canada, but the rest of the G7, particularly Japan and Australia, is missing. Perhaps this refers to another package? If this is not my plan, it is basically to make a combination of modifying existing timeDate functions and writing those that do not exist. could someone already do this?

+4
source share
1 answer

You can test a function holidayNYSEby entering the function name without parentheses in the console. You can see the relevant part here.

if (y <= 1970) 
   holidays <- c(holidays, as.character(USDecorationMemorialDay(y)))
if (y >= 1971) 
   holidays <- c(holidays, as.character(USMemorialDay(y)))

Apparently, USDecorationMemorialDay is a non-existent holiday and is relevant only to the years until 1971.

R, . , -?

+2

Source: https://habr.com/ru/post/1534302/


All Articles