I am having a problem that requires me to count the number of observations in the response column (1s and 0s only) grouped by IDs and based on varying reference dates. I am thinking of using dplyr summarise as a solution but I could not make it work if I take into consideration the said dates.
Sample Data:
CustomerID AccountID OpenDate Response
AAA 456 2020-01-01 1
AAA 456 2020-01-03 1
AAA 456 2020-01-05 1
BBB 789 2020-02-01 1
BBB 789 2020-02-22 0
BBB 789 2020-03-01 1
Desired Count Result:
CustomerID AccountID OpenDate Count
AAA 456 2020-01-01 1
AAA 456 2020-01-03 2
AAA 456 2020-01-05 3
BBB 789 2020-02-01 1
BBB 789 2020-02-22 1
BBB 789 2020-03-01 2
Notice that as the dates go farther, the response count increases because it took into consideration the movement of days.