How to define holidays for is.holiday() chron package in R

后端 未结 3 860
感情败类
感情败类 2020-12-29 14:42

I\'m trying to use chron\'s is.holiday() function, but I\'m having trouble getting it to work. The documentation says to modify the .Holiday

3条回答
  •  既然无缘
    2020-12-29 14:47

    I was trying to do the same thing and found this older post. I didn't need to modify .Holidays:

    library(timeDate);library(chron)
    hlist <- c("USChristmasDay","USGoodFriday","USIndependenceDay","USLaborDay",
        "USNewYearsDay","USThanksgivingDay")        
    myholidays  <- dates(as.character(holiday(2000:2013,hlist)),format="Y-M-D")
    
    > is.holiday(as.Date("2013-11-28"),myholidays)
    
    [1] TRUE
    
    > chron::.Holidays
      New Years Day     Memorial Day Independence Day        Labor Day     Thanksgiving        Christmas 
        01/01/92         05/25/92         07/04/92         09/07/92         11/26/92         12/25/92 
    

提交回复
热议问题