I would like some help if possible as I am new to R in filtering after a certain date and then summing the results.
For example, we have these organisations:
And in these organisations I want to know the consecutive sum of the recent 1's.
For example - A would Return 3 - B would return 1 and C would return 0 and D would also return 1.
The reason being for i.e. B is the most recent date was a 1 - failure but the week before was a success.
I have made some code to pull out the max date of the last 0 (pass) and have this saved in a different DF:

How would I apply this filter (second image/df) to my first dataframe only keeping the most recent dates i.e. the most recent consecutive 1's.
Or if there is a better way to tell r to read the most recent date and add columns until it hits a 0 column by row that would also be appreciated. I tried to have it count the highest consecutive numbers but if the dataframe was other a bigger time period, it would only show the largest failings in the past and I only need the most recent data.
I am new to this so any feedback in language or this query would be appreciated.
My current Code:
Trade_MCAD <- read_excel ("C:/Users/FiercePC/OneDrive/Desktop/Dates MS3 KPI Example/Trade/missed bin.xlsx", sheet=3)
Trade_MCAD$Date <- as.Date(Trade_MCAD$Date)
Trade_MCMaxD <- Trade_MCAD %>%
group_by(Organisation) %>%
filter(Date == max(Date))
Trade_MC0 <- Trade_MCAD[!grepl("1", Trade_MCAD$Collection),]
Trade_MC0 <- Trade_MC0 %>%
group_by(Organisation) %>%
filter(Date == max(Date))
