mercredi 13 janvier 2021

How can I change ggplot (timeseries) based on checkbox in Shiny?

my question is above.

My dataframe:

   Month              City   CountInfected
1      2 Baden-Württemberg         19
2      3 Baden-Württemberg      15314
3      4 Baden-Württemberg      17032
4      5 Baden-Württemberg       2524
5      6 Baden-Württemberg        859
6      7 Baden-Württemberg       1700
7      8 Baden-Württemberg       4912
8      9 Baden-Württemberg       7645
9     10 Baden-Württemberg      33042
10    11 Baden-Württemberg        526
11     1            Bayern          9
12     2            Bayern         14
13     3            Bayern      18230
14     4            Bayern      24683
15     5            Bayern       4218
16     6            Bayern       1361
17     7            Bayern       2590
18     8            Bayern       6624
19     9            Bayern      10978
20    10            Bayern      39459
.
.
.

and my ggplot code:

ggplot(corona_city, aes(x=Month, y = CountInfected)) + 
  geom_line(aes(color = City)) +
  ggtitle("Covid19-Data")

I tried it with a subset function inside ggplot, but this would be too much hardcoding and inefficient, because then I have to write all combinations in an if-else block.

I need a function with the checkboxes and ggplot like on this site: https://covid19germany.mdc-berlin.de/ to change the ggplot reactive.

I hope you guys can help me.




Aucun commentaire:

Enregistrer un commentaire