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

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

    While the function-based answers are slick, Joshua's last comment is spot-on. If you've got a variable you use regularly, either create it in your .Rprofile or load it from an .Rdata file, using some line in .Rprofile like load('daysofweek.rdata') .

    Note that changing the first day of the week is as simple as

    neworder <- days.of.week[c(2:7,1)]

提交回复
热议问题