How can I select current number of the day of week?
For example today it's Tuesday, i.e. 2nd day, so the expected output is "2".
This code return name
weekdays(Sys.Date())
But I need a number.
How can I select current number of the day of week?
For example today it's Tuesday, i.e. 2nd day, so the expected output is "2".
This code return name
weekdays(Sys.Date())
But I need a number.
From lubridate
you can use the wday
function:
library(lubridate)
wday(Sys.Date())
[1] 3
Note that in this function Sunday is the first day of the week, so the number for Tuesday is 3
.