Creating a circular list in R
I am working with a delivery schedule where I need to calculate the days in each unique delivery period. I was trying to solve my related issue in excel originally, but am now thinking I need to use R instead.
If I have list of the days of the week:
DaysOfWeek <- list("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
I always want to be able to reference the list and calculate days forward.
For example, if the delivery schedule is Delivery period 1: Friday-Monday, and period 2: is Tuesday-Thursday. I want to be able to reference my list say delivery day 1 is Friday, count forward until the next delivery day, Tuesday, and see that there are four delivery days in that period.
I have tried hard coding specific dates and setting them to the days of the week as well as several different for loops and am still struggling.
You could do:
This example would return the result
2.