How do I find the week number from an arbitrary start date in R. Let's say I want my start date to be august 1st.
Asked
Active
Viewed 49 times
2 Answers
1
Using lubridate
, you can do:
interval(today(), dmy("21-08-2020"))/weeks(1)
[1] 30.42857
Or from the date of interest to another date:
interval(dmy("21-08-2020"), dmy("21-09-2020"))/weeks(1)
[1] 4.428571

tmfmnk
- 38,881
- 4
- 47
- 67
0
You can use difftime
for this:
difftime("2020-08-21", Sys.Date(), units = "weeks")
# Time difference of 30.45238 weeks

sm925
- 2,648
- 1
- 16
- 28