Skip to content

Instantly share code, notes, and snippets.

@gka
Last active August 31, 2023 14:44
Show Gist options
  • Save gka/251c6026c7ca33ab8e64ecd13a98a4c9 to your computer and use it in GitHub Desktop.
Save gka/251c6026c7ca33ab8e64ecd13a98a4c9 to your computer and use it in GitHub Desktop.
covid19 berlin cases
.Rhistory
.Rproj.user
covid19-berlin.Rproj
.Renviron
date new new.deaths new.avg pred
2020-03-01 - - - -
2020-03-02 2 - - 118.42879442102877
2020-03-03 3 - - 117.37225515742375
2020-03-04 6 - - 116.32496538693616
2020-03-06 7 - 8.142857142857142 115.28641590958122
2020-03-07 9 - 16.428571428571427 114.2560975253742
2020-03-08 20 - 21.714285714285715 113.23350103433032
2020-03-10 10 - 35.857142857142854 112.21811723646493
2020-03-11 60 - 37.714285714285715 111.20943693179319
2020-03-13 40 - 43.42857142857143 110.20695092033041
2020-03-14 105 - 47.857142857142854 109.21015000209186
2020-03-15 20 - 65.85714285714286 108.21852497709276
2020-03-16 49 - 81.42857142857143 107.23156664534834
2020-03-17 51 - 101.42857142857143 106.24876580687395
2020-03-18 136 - 108.85714285714286 105.2696132616848
2020-03-19 169 - 112.57142857142857 104.29359980979612
2020-03-20 180 - 126.71428571428571 103.32021625122321
2020-03-21 157 0 148.85714285714286 102.34895338598129
2020-03-22 46 0 160.85714285714286 101.37930201408565
2020-03-23 148 1 178.42857142857142 100.41075293555156
2020-03-24 206 1 183.42857142857142 99.44279695039421
2020-03-25 220 1 187.42857142857142 98.47492485862894
2020-03-26 292 4 198.71428571428572 97.50662746027096
2020-03-27 215 0 194.57142857142858 96.53739555533554
2020-03-28 185 1 193.14285714285714 95.56671994383792
2020-03-29 125 2 192.57142857142858 94.5940914257934
2020-03-30 119 2 183.71428571428572 93.61900080121718
2020-03-31 196 2 190.57142857142858 92.6450772852556
2020-04-01 216 2 184.14285714285714 91.67633317748465
2020-04-02 230 3 175 90.71283390456418
2020-04-03 263 2 183 89.75464489315401
2020-04-04 140 2 180.14285714285714 88.80183156991401
2020-04-05 61 2 174.14285714285714 87.85445936150398
2020-04-06 175 2 162 86.9125936945838
2020-04-07 176 4 137.14285714285714 85.97629999581329
2020-04-08 174 5 132.42857142857142 85.04564369185232
2020-04-09 145 5 128 84.12069020936069
2020-04-10 89 4 115 83.20150497499827
2020-04-11 107 4 99.71428571428571 82.28815341542486
2020-04-12 30 1 94 81.38070095730033
2020-04-13 84 5 87.71428571428571 80.47921302728453
2020-04-14 69 6 92.14285714285714 79.5837550520373
2020-04-15 134 12 90.57142857142857 78.69439245821845
2020-04-16 101 10 91.71428571428571 77.81119067248784
2020-04-17 120 7 85.42857142857143 76.9342151215053
2020-04-18 96 1 86.42857142857143 76.0635312319307
2020-04-19 38 2 69.28571428571429 75.19920443042383
2020-04-20 40 3 72.14285714285714 74.34130014364459
2020-04-21 76 8 63 73.48988379825278
2020-04-22 14 - 60 72.64502082090826
2020-04-23 121 - 59.857142857142854 71.80677663827085
2020-04-24 56 1 58.857142857142854 70.9752166770004
2020-04-25 75 10 56.714285714285715 70.13759420038875
2020-04-26 37 2 66.57142857142857 69.28254268290105
2020-04-27 33 2 57.857142857142854 68.41219786795712
2020-04-28 61 10 57.714285714285715 67.52869549897676
2020-04-29 83 10 51.857142857142854 66.63417131937987
2020-04-30 60 2 51.42857142857143 65.73076107258619
2020-05-01 55 3 51.285714285714285 64.82060050201558
2020-05-02 34 2 49.714285714285715 63.90582535108788
2020-05-03 34 0 46 62.98857136322291
2020-05-04 32 0 46 62.07097428184046
2020-05-05 50 5 42.857142857142854 61.15516985036039
2020-05-06 57 3 40.857142857142854 60.243293812202495
2020-05-07 60 1 37.57142857142857 59.337481910786636
2020-05-08 33 1 33.285714285714285 58.43986988953261
2020-05-09 20 1 29.714285714285715 57.55259349186026
2020-05-10 11 0 27.857142857142858 56.677788461189394
2020-05-11 2 0 27.142857142857142 55.81759054093984
2020-05-12 25 5 26.857142857142858 54.97413547453144
2020-05-13 44 3 26.714285714285715 54.149559005383985
2020-05-14 55 4 26.714285714285715 53.34599687691734
2020-05-15 31 4 29.285714285714285 52.565584832551295
2020-05-16 19 0 29.857142857142858 51.8104586157057
2020-05-17 11 -1 30.571428571428573 51.082753969800365
2020-05-18 20 2 27 50.38460663825512
2020-05-19 29 4 26.714285714285715 49.71815236448979
2020-05-20 49 0 27.571428571428573 49.0337262391339
2020-05-21 30 4 26.714285714285715 48.2849238749796
2020-05-22 29 0 25.285714285714285 47.478771798690595
2020-05-23 25 1 24.142857142857142 46.62229653693059
2020-05-24 5 0 21.428571428571427 45.72252461636336
2020-05-25 10 0 22.142857142857142 44.78648256365256
2020-05-26 21 2 22.142857142857142 43.82119690546196
2020-05-27 30 2 23.285714285714285 42.833694168455246
2020-05-28 35 1 24.857142857142858 41.83100087929616
2020-05-29 29 1 26.714285714285715 40.820143564648426
2020-05-30 33 1 28.714285714285715 39.80814875117574
2020-05-31 16 0 28.285714285714285 38.80204296554184
2020-06-01 23 0 29.714285714285715 37.80885273441043
2020-06-02 35 0 28.142857142857142 36.83560458444526
2020-06-03 27 2 28.142857142857142 35.88932504231001
2020-06-04 45 0 28.571428571428573 34.977040634668434
2020-06-05 18 1 29 34.105777888184235
2020-06-06 33 4 29.714285714285715 33.282563329521146
2020-06-07 19 0 33.57142857142857 32.51442348534288
2020-06-08 26 0 31.285714285714285 31.808384882313153
2020-06-09 40 1 41.142857142857146 31.171474047095682
2020-06-10 54 2 40.714285714285715 30.6107175063542
2020-06-11 29 0 43.714285714285715 30.13314178675242
2020-06-12 87 0 46.714285714285715 29.74577341495407
2020-06-13 30 0 45.714285714285715 29.455638917622856
2020-06-14 40 0 48.42857142857143 29.25056077230647
2020-06-15 47 0 62.57142857142857 29.111411577222196
2020-06-16 33 1 68.71428571428571 29.034793040038153
2020-06-17 73 1 74.57142857142857 29.01730686842247
2020-06-18 128 1 73 29.05555477004326
2020-06-19 130 0 78.14285714285714 29.14613845256865
2020-06-20 71 0 81.85714285714286 29.28565962366676
2020-06-21 29 0 78 29.470719991005716
2020-06-22 83 0 70.42857142857143 29.697921262253626
2020-06-23 59 0 58.857142857142854 29.96386514507864
2020-06-24 46 1 52 30.265153347148857
2020-06-25 75 0 49 30.598387576132414
2020-06-26 49 1 43.42857142857143 30.960169539697418
2020-06-27 23 0 38.285714285714285 31.347100945511997
2020-06-28 8 0 40.142857142857146 31.755783501244277
2020-06-29 44 1 35.57142857142857 32.182818914562375
2020-06-30 23 0 35.42857142857143 32.62480889313442
2020-07-01 59 0 38 33.07835514462853
2020-07-02 43 0 39.285714285714285 33.540059376712826
2020-07-03 48 0 34.57142857142857 34.00652329705544
2020-07-04 41 1 37 34.47434861332448
2020-07-05 17 0 33.57142857142857 34.94013703318807
2020-07-06 11 0 34.42857142857143 35.40049026431434
2020-07-07 40 0 32 35.85201001437141
2020-07-08 35 1 29 36.2912979910274
2020-07-09 49 0 26.714285714285715 36.71495590195043
2020-07-10 31 0 27.714285714285715 36.9968781497582
2020-07-11 20 1 24.571428571428573 37.030550647955444
2020-07-12 1 0 23.142857142857142 36.841962370540806
2020-07-13 18 2 19.857142857142858 36.45710229151298
2020-07-14 18 1 18.714285714285715 35.90195938487063
2020-07-15 25 1 19.428571428571427 35.202522624612406
2020-07-16 26 0 20.142857142857142 34.384780984737
2020-07-17 23 0 20.857142857142858 33.474723439243064
2020-07-18 25 0 23.285714285714285 32.498338962129296
2020-07-19 6 0 23 31.481616527394333
2020-07-20 23 0 24.142857142857142 30.450545109036852
2020-07-21 35 1 29.857142857142858 29.43111368105552
2020-07-22 23 0 31.142857142857142 28.449311217449022
2020-07-23 34 0 31.714285714285715 27.531126692216013
2020-07-24 63 1 31.142857142857142 26.702549079355165
2020-07-25 34 0 33.42857142857143 25.989567352865144
2020-07-26 10 0 41.42857142857143 25.41817048674462
2020-07-27 19 0 42.57142857142857 25.01434745499227
2020-07-28 51 0 45.285714285714285 24.80408723160675
2020-07-29 79 0 46.857142857142854 24.813378790586746
2020-07-30 42 0 46.714285714285715 25.068211105930907
2020-07-31 82 0 49.57142857142857 25.594573151637917
2020-08-01 45 0 46.857142857142854 26.41845390170644
2020-08-02 9 0 48.57142857142857 27.565842330135137
2020-08-03 39 0 50.142857142857146 29.06272741092269
2020-08-04 32 0 52.285714285714285 30.50052664856465
2020-08-05 91 1 52.714285714285715 31.487779462339557
2020-08-06 53 0 52.857142857142854 32.07615769842052
2020-08-07 97 0 53.285714285714285 32.31733320298068
2020-08-08 48 0 64.57142857142857 32.26297782219317
2020-08-09 10 0 69.42857142857143 31.964763402231082
2020-08-10 42 0 80.57142857142857 31.47436178926757
2020-08-11 111 0 79.42857142857143 30.843444829475754
2020-08-12 125 0 78.57142857142857 30.12368436902876
2020-08-13 131 0 79.28571428571429 29.3667522540997
2020-08-14 89 0 82.71428571428571 28.624320330861714
2020-08-15 42 0 77.57142857142857 27.948060445487922
2020-08-16 15 0 69.57142857142857 27.38964444415145
2020-08-17 66 0 62.285714285714285 27.000744173025428
2020-08-18 75 0 65.57142857142857 26.833031478282983
2020-08-19 69 0 68.42857142857143 26.938178206097213
2020-08-20 80 2 67.85714285714286 27.36785620264127
2020-08-21 112 0 66.71428571428571 28.173737314088285
2020-08-22 62 0 65.42857142857143 29.407493386611357
2020-08-23 11 0 67.28571428571429 31.120796266383643
2020-08-24 58 0 66.85714285714286 33.36531779957824
2020-08-25 66 0 67.14285714285714 36.19272983236829
2020-08-26 82 0 66.57142857142857 39.65470421092692
2020-08-27 77 0 65.85714285714286 43.80291278142723
2020-08-28 114 0 68.57142857142857 48.689027390042384
2020-08-29 58 0 70.71428571428571 54.11463930747508
2020-08-30 6 0 71 59.83919762799815
2020-08-31 77 0 74 65.85116093313985
2020-09-01 81 0 71.14285714285714 72.13898780442845
2020-09-02 84 0 74.28571428571429 78.69113682339227
2020-09-03 98 0 76.85714285714286 85.49606657155948
2020-09-04 94 0 75.14285714285714 92.54223563045846
2020-09-05 80 0 76 99.8181025816174
2020-09-06 24 0 74.28571428571429 107.31212600656461
2020-09-07 65 0 80.14285714285714 115.01276448682833
2020-09-08 87 0 84.71428571428571 122.90847660393685
2020-09-09 72 0 78.71428571428571 130.98772093941844
2020-09-10 139 0 77.42857142857143 139.23895607480137
2020-09-11 126 0 80.28571428571429 147.65064059161392
2020-09-12 38 0 83.42857142857143 156.21123307138433
2020-09-13 15 0 91.71428571428571 164.90919209564086
2020-09-14 85 0 91.85714285714286 173.73297624591183
2020-09-15 109 1 100.42857142857143 182.67104410372545
2020-09-16 130 0 115.85714285714286 191.71185425061003
2020-09-17 140 0 120 200.84386526809388
2020-09-18 186 0 129 210.0555357377051
2020-09-19 146 0 130.14285714285714 219.3353242409722
2020-09-20 44 0 140 228.6716893594233
2020-09-21 148 0 154 238.0530896745867
2020-09-22 117 1 150.14285714285714 247.46798376799066
2020-09-23 199 0 149.71428571428572 257.45070780412976
2020-09-24 238 0 155.28571428571428 268.48705772809257
2020-09-25 159 0 152.85714285714286 280.4926817922983
2020-09-26 143 0 160.85714285714286 293.38322824916634
2020-09-27 83 0 173.57142857142858 307.07434535111594
2020-09-28 131 0 174.42857142857142 321.4816813505662
2020-09-29 173 0 200.14285714285714 336.5208844999367
2020-09-30 288 0 208.71428571428572 352.1076030516465
2020-10-01 244 1 207.42857142857142 368.1574852581149
2020-10-02 339 2 231.71428571428572 384.5861793717613
2020-10-03 203 0 248.14285714285714 401.3093336450048
2020-10-04 74 0 261 418.2425963302648
2020-10-05 301 0 297.2857142857143 435.30161567996066
2020-10-06 288 0 312.14285714285717 452.4020399465115
2020-10-07 378 1 322.14285714285717 469.45951738233657
2020-10-08 498 1 346.85714285714283 486.3896962398552
2020-10-09 443 1 339.85714285714283 503.10822477148673
2020-10-10 273 0 399.57142857142856 519.5307512296505
2020-10-11 247 0 417.42857142857144 535.5729238667656
2020-10-12 252 0 425 551.1503909352514
2020-10-13 706 2 458.2857142857143 566.1788006875271
2020-10-14 503 0 471.14285714285717 580.57380137601206
2020-10-15 551 2 479 594.2510412531254
2020-10-16 676 1 511 607.1261685712869
2020-10-17 363 0 527.5714285714286 619.1148315829153
2020-10-18 302 2 594.4285714285714 630.13267854043
2020-10-19 476 0 627.5714285714286 641.200220945286
2020-10-20 822 2 658.5714285714286 653.3245019533091
2020-10-21 971 0 666.1428571428571 666.4009672984739
2020-10-22 783 2 666.4285714285714 680.3250627147552
2020-10-23 893 3 731.2857142857143 694.9922339361283
2020-10-24 416 1 762.4285714285714 710.2979266965675
2020-10-25 304 1 789.5714285714286 726.137586730048
2020-10-26 930 1 839.2857142857143 742.4066597705447
2020-10-27 1040 0 866.5714285714286 759.0005915520328
2020-10-28 1161 2 920.1428571428571 775.8148278084865
2020-10-29 1131 0 928.4285714285714 792.7448142738812
2020-10-30 1084 2 897.4285714285714 809.6859966821914
2020-10-31 791 6 965 826.5338207673924
2020-11-01 362 0 963.1428571428571 843.183732263459
2020-11-02 713 0 999.7142857142857 859.5311769043657
2020-11-03 1513 4 1034.7142857142858 875.4716004240877
2020-11-04 1148 7 1021.2857142857143 890.9004485565999
2020-11-05 1387 15 1004 905.7131670358771
2020-11-06 1329 5 1022.1428571428571 919.8052015958942
2020-11-07 697 2 1028 933.0719979706263
2020-11-08 241 1 1025.7142857142858 945.4090018940478
2020-11-09 840 6 1107.5714285714287 956.71165910013406
2020-11-10 1554 12 1107.4285714285713 966.8754153228597
2020-11-11 1132 8 1126.5714285714287 975.7957162961998
2020-11-12 1960 12 1153.857142857143 983.3680077541289
2020-11-13 1328 15 1224.857142857143 990.2725639348561
2020-11-14 831 10 1227.4285714285713 997.2385220553429
2020-11-15 432 4 1273.857142857143 1004.234622317694
2020-11-16 1337 9 1172.5714285714287 1011.2296049240143
2020-11-17 1572 22 1226.142857142857 1018.1922100764091
2020-11-18 1457 8 1257.5714285714287 1025.0911779769822
2020-11-19 1251 21 1258.142857142857 1031.8952488278392
2020-11-20 1703 19 1182.142857142857 1038.5731628310846
2020-11-21 1051 6 1188.2857142857142 1045.0936601888234
2020-11-22 436 2 1213 1051.4254811031599
2020-11-23 805 7 1192.857142857143 1057.5373657761993
2020-11-24 1615 36 1149.5714285714287 1063.3980544100461
2020-11-25 1630 16 1117.142857142857 1068.9762872068056
2020-11-26 1110 19 1102.2857142857142 1074.240804368582
2020-11-27 1400 12 1119.4285714285713 1079.1603460974807
2020-11-28 824 11 1054.5714285714287 1083.7036525956057
2020-11-29 332 3 958.5714285714286 1087.8394640650624
2020-11-30 925 12 977.7142857142857 1091.5365207079556
2020-12-01 1161 29 957.7142857142857 1094.7635627263896
2020-12-02 958 24 1028.5714285714287 1097.4893303224696
2020-12-03 1244 23 1031.857142857143 1099.6825636983006
2020-12-04 1260 16 991.1428571428571 1101.3120030559867
2020-12-05 1320 22 1017.8571428571429 1102.3463885976334
2020-12-06 355 4 1041.4285714285713 1102.7544605253452
2020-12-07 640 16 1100.2857142857142 1102.5049590412264
2020-12-08 1348 33 1063.4285714285713 1101.1822011813915
2020-12-09 1123 17 1023.1428571428571 1098.4592167168203
2020-12-10 1656 19 1050.7142857142858 1094.4378149519168
2020-12-11 1002 22 1103.2857142857142 1089.2198051910855
2020-12-12 1038 23 1072 1082.9069967387304
2020-12-13 548 8 1094.857142857143 1075.6011988992548
2020-12-14 1008 25 1068.7142857142858 1067.404220977064
2020-12-15 1129 53 1146.2857142857142 1058.4178722765612
2020-12-16 1283 29 1187.2857142857142 1048.743962102151
2020-12-17 1473 30 1182.7142857142858 1038.4842997582375
2020-12-18 1545 26 1174.857142857143 1027.7406945492246
2020-12-19 1325 17 1228.4285714285713 1016.6149557795163
2020-12-20 516 6 1272.7142857142858 1005.2088927535169
2020-12-21 953 17 1198.2857142857142 993.6243147756306
2020-12-22 1504 42 1017.2857142857143 981.9630311502615
2020-12-23 1593 39 918.7142857142857 970.3268511818135
2020-12-24 952 11 961.4285714285714 958.8175841746908
2020-12-25 278 2 917.5714285714286 947.5370394332973
2020-12-26 635 10 886.5714285714286 936.5870262620375
2020-12-27 815 21 810.2857142857143 926.0693539653155
2020-12-28 646 23 766.1428571428571 916.085831847535
2020-12-29 1287 41 756 906.7382692131005
2020-12-30 1059 34 731 898.128475366416
2020-12-31 643 24 708.2857142857143 890.3582596118853
2021-01-01 207 6 726.1428571428571 883.5294312539129
2021-01-02 460 8 718.7142857142857 876.7650189981721
2021-01-03 656 20 754 869.1722952875905
2021-01-04 771 22 886.2857142857143 860.8294350324536
2021-01-05 1235 63 1068 851.814613143047
2021-01-06 1306 55 1106.857142857143 842.2060045296566
2021-01-07 1569 42 1061.7142857142858 832.0817841025673
2021-01-08 1479 60 1099.5714285714287 821.520126772065
2021-01-09 732 13 1076 810.5992074484355
2021-01-10 340 5 1064 799.3972010419641
2021-01-11 1036 26 1014.4285714285714 787.9922824629364
2021-01-12 1070 44 944.5714285714286 776.4626266216378
2021-01-13 1222 76 910.7142857142857 764.886408428354
2021-01-14 1222 44 902.7142857142857 753.3418027933707
2021-01-15 990 45 832.4285714285714 741.9069846269731
2021-01-16 495 22 797.2857142857143 730.6601288394473
2021-01-17 284 11 727.2857142857143 719.6794103410782
2021-01-18 544 27 681.4285714285714 709.0430040421518
2021-01-19 824 58 627.8571428571429 698.8290848529534
2021-01-20 732 39 623.2857142857143 689.1158276837688
2021-01-21 901 39 605.5714285714286 679.9814074448835
2021-01-22 615 25 580.5714285714286 671.5039990465829
2021-01-23 463 18 524.7142857142857 663.7617773991527
2021-01-24 160 1 547.2857142857143 656.8329174128784
2021-01-25 369 27 490.42857142857144 650.7955939980457
2021-01-26 433 34 482 645.7279820649399
2021-01-27 890 63 457.42857142857144 641.1060829725412
2021-01-28 503 31 454.57142857142856 636.3663633213026
2021-01-29 556 40 466.85714285714283 631.5276958837181
2021-01-30 291 29 455.42857142857144 626.6089534322822
2021-01-31 140 12 420.2857142857143 621.6290087394894
2021-02-01 455 17 417.57142857142856 616.6067345778335
2021-02-02 353 33 388.42857142857144 611.5610037198095
2021-02-03 644 48 378.57142857142856 606.5106889379111
2021-02-04 484 44 380.85714285714283 601.4746630046334
2021-02-05 352 35 356.42857142857144 596.47179869247
2021-02-06 222 13 349.14285714285717 591.5209687739155
2021-02-07 156 4 335.14285714285717 586.6410460214641
2021-02-08 284 15 322.57142857142856 581.8509032076105
2021-02-09 302 21 327.14285714285717 577.1694131048488
2021-02-10 546 50 324.57142857142856 572.6154484856734
2021-02-11 396 17 312.42857142857144 568.2078821225784
2021-02-12 384 24 299.85714285714283 563.9655867880584
2021-02-13 204 8 299 559.9074352546077
2021-02-14 71 4 284.42857142857144 556.0523002947205
2021-02-15 196 11 295.7142857142857 552.4190546808913
2021-02-16 296 25 294 549.0265711856143
2021-02-17 444 25 300.85714285714283 545.893722581384
2021-02-18 475 32 301.14285714285717 543.0393816406946
2021-02-19 372 18 314.14285714285717 540.4824211360404
2021-02-20 252 7 310.14285714285717 538.2417138399159
2021-02-21 73 1 315.7142857142857 536.1889511322245
2021-02-22 287 12 320.7142857142857 534.1877202025952
2021-02-23 268 26 338.57142857142856 532.2447375381108
2021-02-24 483 15 347 530.3667196258532
2021-02-25 510 24 351.2857142857143 528.5603829529057
2021-02-26 497 9 344.85714285714283 526.8324440063498
2021-02-27 311 4 375.42857142857144 525.1896192732687
2021-02-28 103 0 370.2857142857143 523.6386252407445
2021-03-01 242 7 384.2857142857143 522.1861783958601
2021-03-02 482 25 372.57142857142856 520.8389952256975
2021-03-03 447 12 372.85714285714283 519.6037922173393
2021-03-04 608 12 373.85714285714283 518.4872858578681
2021-03-05 415 15 351.85714285714283 517.4961926343664
2021-03-06 313 3 324 516.6372290339166
2021-03-07 110 2 330 515.9171115436012
2021-03-08 88 1 322.14285714285717 515.3425566505025
2021-03-09 287 7 354.85714285714283 514.9202808417032
2021-03-10 489 16 382.7142857142857 514.6570006042857
2021-03-11 553 10 396.7142857142857 514.5594324253324
2021-03-12 644 5 436.42857142857144 514.6342927919259
2021-03-13 508 1 490 514.8882981911486
2021-03-14 208 0 510.14285714285717 515.3281651100831
2021-03-15 366 8 521 515.9606100358118
2021-03-16 662 5 556.7142857142857 516.792349455417
2021-03-17 630 9 525 517.8300998559815
2021-03-18 629 11 526.5714285714286 519.105348552547
2021-03-19 894 18 552.1428571428571 520.6397303433398
2021-03-20 286 6 564.8571428571429 522.4251829402202
2021-03-21 219 1 656 524.4536440550476
2021-03-22 545 6 709.8571428571429 526.7170513996821
2021-03-23 751 13 721.1428571428571 529.2073426859832
2021-03-24 1268 12 785.2857142857143 531.9164556258108
2021-03-25 1006 3 796.2857142857143 534.8363279310248
2021-03-26 973 4 800.5714285714286 537.9588973134847
2021-03-27 735 6 788 541.2761014850506
2021-03-28 296 3 751.4285714285714 544.7798781575823
2021-03-29 575 4 779.8571428571429 548.4621650429392
2021-03-30 663 4 710 552.3148998529815
2021-03-31 1012 8 716.1428571428571 556.3300202995687
2021-04-01 1205 16 718 560.4994640945607
2021-04-02 484 10 663.5714285714286 564.8151689498173
2021-04-03 778 1 654.7142857142857 569.2690725771985
2021-04-04 309 4 588 573.8531126885637
2021-04-05 194 0 547.7142857142857 578.5592269957727
2021-04-06 601 4 624.1428571428571 583.3793532106855
2021-04-07 545 8 604.8571428571429 588.3054290451619
2021-04-08 923 12 631.1428571428571 593.3293922110616
2021-04-09 1019 12 - 598.4431804202444
2021-04-10 643 1 - 603.63873138457
2021-04-11 493 0 - 608.9079828158984
needs(tidyverse, ggtext, zoo, modelr)
source('./write_datawrapper.R')
# load data from Jakub's Github repository
covid19 <- read_csv('https://raw.githubusercontent.com/jakubvalenta/covid-berlin-data/master/covid_berlin_data_incl_hospitalized.csv') %>%
# compute new cases
mutate(new=cases - lag(cases),
# compute new deaths
new.deaths=deaths-lag(deaths),
# compute rolling average over 7
new.avg=rollmean(new, 7, align = 'center', na.pad = T),
# add row number index
index=row_number())
# compute Loess prediction for new cases
mod <- loess(new ~ index, covid19, na.action='na.exclude', span=0.5)
# store dataset
covid19 %>%
add_predictions(mod) %>%
select(date, new, new.deaths, new.avg, pred) %>%
mutate(pred=ifelse(pred<0, NA, pred)) %>%
write_datawrapper('RnWgL') %>%
write_csv('covid19-cases-berlin.csv', na = '-')
# create R plot for reference
png('covid19-berlin-new.png', width =20, height=15, units='cm',
res=120)
covid19 %>%
add_predictions(mod) %>%
ggplot(aes(date, new)) +
geom_col(fill='#aeebd9') +
geom_col(aes(y=new.deaths), fill='#15607a') +
geom_hline(aes(yintercept=0)) +
geom_area(aes(y=new.avg), fill='#29a793', alpha=0.2) +
geom_line(aes(y=new.avg), color='#29a793', size=1) +
geom_line(aes(y=pred), color='#000000', span=0.45, se=F, linetype=3, size=0.7) +
scale_x_date(name='')+
scale_y_continuous(name='', limits = c(0, NA))+
labs(title='New COVID-19 cases in Berlin per day',
subtitle = paste('**bars** = reported number of new <b style="color:#7bd1b8">cases</b> and <b style="color:#15607a">deaths</b> per day',
'**lines** = 7-day average number of cases (solid) + loess smooth (dotted)', sep='<br>'),
caption='Source: Pressemitteilungen der Senatsverwaltung für Gesundheit, Pflege und Gleichstellung\nData via https://github.com/jakubvalenta/covid-berlin-data') +
theme_minimal() +
theme(text = element_text(size = 12),
plot.title = element_markdown(size = 17, face = 'bold'),
plot.subtitle = element_markdown(size = 12),
plot.caption = element_text(color='#777777'),
plot.margin=unit(c(0.4,0.2,0.49,0),'cm'))
dev.off()
# compute different moving average spans
covid19 %>%
select(date, index, new) %>%
mutate(zero=0,
average3=rollmean(new, 3, align = 'center', na.pad = T),
average7=rollmean(new, 7, align = 'center', na.pad = T),
average10=rollmean(new, 10, align = 'center', na.pad = T),
average14=rollmean(new, 14, align = 'center', na.pad = T),
average21=rollmean(new, 21, align = 'center', na.pad = T)) %>%
write_datawrapper('RBL4y') %>%
ggplot(aes(date, new)) +
geom_col(fill='#aeebd9') +
geom_hline(aes(yintercept=0)) +
geom_line(aes(y=average3), color=1, size=1) +
geom_line(aes(y=average7), color=1, size=1) +
geom_line(aes(y=average10), color=4, size=1) +
geom_line(aes(y=average14), color=2, size=1) +
geom_line(aes(y=average21), color=3, size=1) +
scale_x_date(name='')+
scale_y_continuous(name='', limits = c(0, NA))+
theme_minimal()
# different moving average alignments
covid19 %>%
select(date, index, new) %>%
add_predictions(mod) %>%
mutate(pred=ifelse(pred<0, NA, pred)) %>%
mutate(zero=0,
average.left=rollmean(new, 14, align = 'left', na.pad = T),
average.center=rollmean(new, 14, align = 'center', na.pad = T),
average.right=rollmean(new, 14, align = 'right', na.pad = T)) %>%
write_datawrapper('MiExN') %>%
ggplot(aes(date, new)) +
geom_col(fill='#aeebd9') +
geom_hline(aes(yintercept=0)) +
geom_line(aes(y=pred), color=1, size=0.5) +
geom_line(aes(y=average.left), color=1, size=1) +
geom_line(aes(y=average.center), color=1, size=1) +
geom_line(aes(y=average.right), color=4, size=1) +
scale_x_date(name='')+
scale_y_continuous(name='', limits = c(0, NA))+
theme_minimal()
covid19 %>%
select(date, new) %>%
mutate(zero=0,
average3=rollmean(new, 3, align = 'center', na.pad = T),
average7=rollmean(new, 7, align = 'center', na.pad = T),
average14=rollmean(new, 14, align = 'center', na.pad = T),
average21=rollmean(new, 21, align = 'center', na.pad = T)) %>%
write_datawrapper('RBL4y') %>%
ggplot(aes(date, new)) +
geom_col(fill='#aeebd9') +
geom_hline(aes(yintercept=0)) +
geom_line(aes(y=average3), color=1, size=1) +
geom_line(aes(y=average7), color=1, size=1) +
geom_line(aes(y=average14), color=2, size=1) +
geom_line(aes(y=average21), color=3, size=1) +
scale_x_date(name='')+
scale_y_continuous(name='', limits = c(0, NA))+
theme_minimal()
covid19 %>%
ggplot(aes(date, hospitalized)) +
geom_col(fill='#aeebd9') +
geom_col(aes(y=icu), fill='#29a793') +
theme_minimal()
needs(tidyverse)
covid19 <- read_csv('https://raw.githubusercontent.com/jakubvalenta/covid-berlin-data/master/covid_berlin_data.csv')
DAYS <- c(
'0'='Sunday',
'1'='Monday',
'2'='Tuesday',
'3'='Wednesday',
'4'='Thursday',
'5'='Friday',
'6'='Saturday')
new_cases <- covid19 %>%
mutate(weekday = DAYS[format(date, '%w')],
new=cases - lag(cases))
new_cases.ts <- ts(new_cases$new, start=0, frequency = 7)
dts <- decompose(new_cases.ts, "multiplicative")
plot(dts)
Display the source blob
Display the rendered blob
Raw
needs(tidyverse, zoo)
data <- read_csv('covid19-cases-berlin.csv', na = '-')
Sys.setlocale("LC_TIME", 'en_GB.UTF-8')
png('covid19-berlin-weekdays.png', width =20, height=15, units='cm',
res=140)
data %>%
filter(date > '2020-03-01') %>%
select(date, new) %>%
# add zero values for February for the rolling average
bind_rows(tibble(date=as.Date(c(paste0('2020-02-',c(1,29)), '2020-03-01'), new=0))) %>%
mutate(wd=as.numeric(format(date, '%u'))) %>%
group_by(wd) %>%
arrange(date) %>%
mutate(new.avg=rollmean(new, 4, align = 'center', na.pad = T)) %>%
ungroup() %>%
arrange(date) %>%
filter(date >= '2020-03-01') %>%
mutate(weekday=fct_reorder(format(date, '%A'), wd, first),
lastweek=date > max(data$date-7)) %>%
ggplot(aes(date, new, color=lastweek)) +
geom_point() +
scale_color_manual(values=c('#00000066','#dd0000'), guide=F) +
facet_wrap(weekday ~ .) +
geom_line(aes(y=new.avg), color=1, size=0.5) +
theme_minimal() +
ggtitle('New COVID-19 cases in Berlin, by weekday',
'Line shows rolling 4-week average, past 7 days highlighted in red')
dev.off()
needs(httr)
readRenviron('~/.Renviron')
write_datawrapper <- function(data, chartid) {
token <- Sys.getenv('dw_api_key')
r <- httr::PUT(
paste0('https://api.datawrapper.de/v3/charts/', chartid,'/data'),
add_headers(Authorization=paste0('Bearer ', token)),
encode = 'raw',
body=format_csv(data, na = '-'))
print(r)
data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment