I am new to R and I am working on a project that requires me to calculated the difference in new cases two weeks from the date that a mask mandate was enforced. My dataset consist of state, date (%y%m%d), mask (yes/no), daily new cases. Therefore, if mask = yes, then I need to calculated the difference in new cases two weeks from the date that the mandate was placed. I am not sure how to code this, much help will be appreciated.
This is a example of a portion of the dataset. It is grouped by state.
Mask date state new_case
NA 2020-07-15 AL 1236
NA 2020-07-16 AL 1254
NA 2020-07-17 AL 1579
Yes 2020-07-18 AL 2003
NA 2020-07-19 AL 1745
NA 2020-07-20 AL 1945
NA 2020-07-21 AL 2114
NA 2020-07-22 AL 1819
NA 2020-07-23 AL 1126
NA 2020-07-24 AL 1282