0

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
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
xbechtel
  • 1
  • 1
  • Can you provide a reproducible example? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – william3031 Dec 01 '20 at 23:35
  • Hello! I added a portion of what my dataset looks like, it is grouped by state. – xbechtel Dec 02 '20 at 00:29
  • So do you mean to calculate this difference starting from 18 July or only for 18 July (ref-sample data)? It would have been much better if you could also append the result column (manually also along with the code) – AnilGoyal Dec 04 '20 at 08:51

0 Answers0