I am trying to run a piece of code to calculate the number of days between 2 dates, whenever a status is changed to the value 1.
below is a sample of the data frame:
I can calculate using the following code between 2 dates no problem, it is when there is a status change between each change i need to calculate the number of days.
df$Date2_Date1 <- difftime(df$Date2,df$Date1, units = c("hours"))