[R] Rolling 7 day incidence
Dr Eberhard Lisse
no@p@m @end|ng |rom ||@@e@NA
Tue Aug 17 12:25:23 CEST 2021
Hi,
I am loading the coronavirus dataset everyday which looks something like:
as_tibble(coronavirus) %>%
filter(country=="Namibia" & type=="confirmed") %>%
arrange(desc(date)) %>%
print(n=10)
# A tibble: 573 × 7
date province country lat long type cases
<date> <chr> <chr> <dbl> <dbl> <chr> <dbl>
1 2021-08-16 "" Namibia -23.0 18.5 confirmed 76
2 2021-08-15 "" Namibia -23.0 18.5 confirmed 242
3 2021-08-14 "" Namibia -23.0 18.5 confirmed 130
4 2021-08-13 "" Namibia -23.0 18.5 confirmed 280
5 2021-08-12 "" Namibia -23.0 18.5 confirmed 214
6 2021-08-11 "" Namibia -23.0 18.5 confirmed 96
7 2021-08-10 "" Namibia -23.0 18.5 confirmed 304
8 2021-08-09 "" Namibia -23.0 18.5 confirmed 160
9 2021-08-08 "" Namibia -23.0 18.5 confirmed 229
10 2021-08-07 "" Namibia -23.0 18.5 confirmed 319
# … with 563 more rows
How do I do a rolling 7 day incidence (ie sum the cases over 7 days) but
rolling, ie from the last day to 7 (or 6?) days before the end of the
dataset, so I get pairs of date/7-Day-Incidence?
I know it's probably re-inventing the plot as it were but I can't find
R code to do that.
I want to plot it per 100000 but that I can do.
greetings, el
--
To email me replace 'nospam' with 'el'
More information about the R-help
mailing list