How can I create a vector containing the days of the week?

前端 未结 4 1975
时光取名叫无心
时光取名叫无心 2021-02-20 12:07

I need a vector containing the days of the week very often, but I always type it out:

days.of.week <- c(\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\",          


        
4条回答
  •  攒了一身酷
    2021-02-20 12:30

    Based on today's date we can also find days of a week

    weekdays(as.Date(seq(7),origin=Sys.Date() - as.POSIXlt(Sys.Date())$wday ))
     [1] "Monday"    "Tuesday"   "Wednesday" "Thursday"  "Friday"    "Saturday" 
     [7] "Sunday"
    

提交回复
热议问题