I am trying to find the total revenue, gross, margin, sales, and inventory by week in R. I believe the easiest way to do this is assign a week number to each date so I can group by or filter for the week number. However, there are multiple years and I can only figure out how to do this so it resets at Week 1 at the beginning of the next year. Is there a way to get around this? Should I add a year column for each of the purchases as well?
WeeklyVariableData$New$WeekNum <- strftime(WeeklyVariableData$New$'Contract Date', format = "%V")
WeeklyVariableData$Used$WeekNum <- strftime(WeeklyVariableData$Used$'Contract Date', format = "%V")
WeeklyVariableData$New$Year <- strftime(WeeklyVariableData$New$'Contract Date', format = "%Y")
WeeklyVariableData$Used$Year <- strftime(WeeklyVariableData$Used$'Contract Date', format = "%Y")