Find the day of a week

前端 未结 7 1870
长情又很酷
长情又很酷 2020-11-22 17:37

Let\'s say that I have a date in R and it\'s formatted as follows.

   date      
2012-02-01 
2012-02-01
2012-02-02

Is there any way in R to

7条回答
  •  粉色の甜心
    2020-11-22 17:48

    Use the lubridate package and function wday:

    library(lubridate)
    df$date <- as.Date(df$date)
    wday(df$date, label=TRUE)
    [1] Wed   Wed   Thurs
    Levels: Sun < Mon < Tues < Wed < Thurs < Fri < Sat
    

提交回复
热议问题