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

前端 未结 4 1999
时光取名叫无心
时光取名叫无心 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:40

    One possibility:

    days.of.week <- weekdays(Sys.Date()+0:6)
    

    Always starting on Monday:

    days.of.week <- weekdays(as.Date(4,"1970-01-01",tz="GMT")+0:6)
    

    Or you could just define it as you have, but in your .Rprofile, so it's always available on startup.

提交回复
热议问题