How to determine if date is a weekend or not (not using lubridate)

前端 未结 7 866
予麋鹿
予麋鹿 2020-11-29 12:00

I have a vector of date objects (yyyy-mm-dd) and I want to determine if any of them are on weekend or not. Is there a function that can determine this straighta

7条回答
  •  甜味超标
    2020-11-29 12:25

    I put @AnandaMahto's suggestion here rather than a comment:

    library(chron)
    x <- seq(Sys.Date()-10, Sys.Date(), by = 1)
    x[is.weekend(x)]
    
    ## [1] "2014-10-11" "2014-10-12" "2014-10-18"
    

提交回复
热议问题