简体   繁体   English

如何在timeDate中访问“正确”的假期

[英]how do I access “correct” holidays in timeDate

Searched around but could not find the answer to this. 搜索过但无法找到答案。 Essentially, the timeDate package has some internal code it hasn't exposed, and I am wondering how to get at it: 从本质上讲,timeDate包有一些它没有暴露的内部代码,我想知道如何得到它:

> 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]

so as you can see here the USDecorationMemorialDay function is wrong as Memorial Day is the last monday of May. 所以你可以在这里看到USDecorationMemorialDay函数是错误的,因为阵亡将士纪念日是五月的最后一个星期一。 however in the holidayNYSE function they have somehow implemented a correction so it gives [2013-05-27]. 但是在holidayNYSE函数中,他们以某种方式实现了修正,因此它给出了[2013-05-27]。 What's up with that? 那是怎么回事?

Bigger picture I'm really looking to have a national holiday calendar by country. 更大的图片我真的希望按国家/地区制作全国假日日历。 timeDate has set up the UK, US, Switzerland, and Canada, but the rest of the G7 in particular Japan and Australia are missing. timeDate已经建立了英国,美国,瑞士和加拿大,但其他七国集团尤其是日本和澳大利亚都没有。 Perhaps this belongs in some other package? 也许这属于其他一些包? If it doesnt my plan is to basically do a mix of modify the existing timeDate functions and write those that dont exist. 如果不是我的计划是基本上混合修改现有的timeDate函数并编写那些不存在的函数。 someone somewhere has probably already done this? 某个地方有人可能已经这样做了吗?

You can inspect the function holidayNYSE function by typing the function name without parentheses in the console. 您可以通过在控制台中键入没有括号的函数名来检查函数holidayNYSE函数。 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 defunct holiday and only relevant for years prior to 1971. 显然,USDecorationMemorialDay是一个已经过时的假期,只与1971年之前相关。

For your bigger picture question, I'm not aware of any R package that does this. 对于你的大图片问题,我不知道有任何R包这样做。 Perhaps you can scrape it from the web somewhere? 也许你可以从网上把它刮掉?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM