0

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.

Gaurav
  • 1,597
  • 2
  • 14
  • 31
Nikolay
  • 131
  • 1
  • 7

1 Answers1

2

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.

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149