When using format(as.Date(c("2020-10-04", "2020-10-05")), "%U")
(the first date is sunday, the second date is monday) I get week 40 for both dates. What do I have to do in order to let the week start on Monday?
Asked
Active
Viewed 167 times
0

Ronak Shah
- 377,200
- 20
- 156
- 213

D. Studer
- 1,711
- 1
- 16
- 35
2 Answers
2
Use "%V"
:
format(as.Date(c("2020-10-04", "2020-10-05")), "%V")
#[1] "40" "41"

Ronak Shah
- 377,200
- 20
- 156
- 213
1
format(as.Date(c("2020-10-04", "2020-10-05")), "%W")
Check out ?strptime
for the full documentation on it

Edo
- 7,567
- 2
- 9
- 19