I have list of days when wages are taken
e.g. wages_days <- "Tuesday,Thursday"
I want to compare wages between the two days
for example if we run wages today 17/05/2022 which is a tuesday I want to know the previous date in the list which will of course be Thursday 12/05/2022
So if we know the date which is todays date which we can calculate is a tuesday using R how do we find the date for the previous thursday
the list could change
ie e.g. wages_days <- "Monday,Tuesday,Thursday"
Can you clarify a bit what exactly you are trying to do? After reading your question, I am a bit unsure which of the following problems you are trying to solve:
How many days are between a given weekday and a prior second given weekday (so if you give a function a "Friday" and a "Tuesday", the function would return 3)?
You have one vector of dates, and you want to figure out what weekday each date is on?
1. Check todays date is one of the days in the list ie a Monday,Wednesday or Thursday
2. If not print error
3. If it is then get the previous date based on the list
e.g. In aboves case if todays date is a Wednesday we would want the date of the Monday
if todays date is a Monday we would want the date of the previous Friday
But I dont want in your example the Week before but the previous day in the list ie if Today is a monday in your example I would want the prev date to be the Friday the week before
I think if today wqs monday my code gives the previous friday. By adding the weekbefore you mean it should be more than 7 days apart ? I.e. two fridays ago ?