Objective
Transform the wide-format global COVID-19 confirmed cases dataset into a tidy (long) format using the tidyr and dplyr packages in R. Once the data has been cleaned up, examine how confirmed COVID-19 cases have evolved over time across nations to find broad global patterns.
Approach
Dataset description
For this project, I will use a global COVID-19 confirmed cases dataset provided by the Johns Hopkins University Center for Systems Science and Engineering (CSSE). The dataset is publicly available and can be accessed here:
https://raw.githubusercontent.com/NafeesKhandker/Project-2-Tidy-Format-Transformation/refs/heads/main/Covid19_confirmed_global.csv
Beginning in January 2020, the dataset includes daily confirmed COVID-19 case counts for various nations and regions worldwide.
At the moment, the dataset is kept in a wide format in which a particular date is represented by each column and a country or region by each row. For instance, the number of confirmed cases reported on those dates is shown in columns like 1/22/20, 1/23/20, and 1/24/20.
The dataset does not adhere to tidy data principles because the date variable is embedded within column headers rather than being stored as a separate variable. Every variable in tidy data should have its own column, and every observation should have its own row.
The following significant variables are included in the dataset:
Province/State : Sub-national region
Country/Region : Country name
Lat : Latitude coordinate
Long : Longitude coordinate
Date columns : Daily confirmed case counts
Anticipated Challenges
One anticipated challenge is handling the extremely large number of date columns in the dataset. These columns span multiple years and must be transformed into a single date variable during the tidying process.
Another potential challenge is the presence of missing values in the Province/State column, since not all countries report regional data. Care must be taken to preserve country information while handling these missing values appropriately.
Additionally, date values stored as column names will need to be converted into proper date formats after the reshaping process.
Implementation of Data Import
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.1 ✔ tibble 3.3.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.2
✔ purrr 1.2.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library (lubridate)
library (gt)
url <- "https://raw.githubusercontent.com/NafeesKhandker/Project-2-Tidy-Format-Transformation/refs/heads/main/Covid19_confirmed_global.csv"
df <- read_csv (file = url, show_col_types = FALSE )
df |>
head (n = 5 ) |>
gt ()
NA
Afghanistan
33.93911
67.70995
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
5
5
5
5
5
5
5
5
5
5
5
8
8
8
8
11
11
11
14
20
25
26
26
26
24
24
34
40
42
74
80
91
106
114
114
166
192
235
269
270
299
337
367
423
444
521
521
555
607
665
770
794
845
908
933
996
1026
1092
1176
1226
1330
1463
1531
1703
1827
1827
2171
2469
2469
2469
2469
3224
3392
3563
3563
4402
4664
4967
4967
5339
6053
6402
6635
7072
7655
8145
8676
9216
9952
10668
11180
11917
12465
13102
13745
14529
15180
15836
16578
17353
17977
19055
19637
20428
21003
21308
22228
22976
23632
24188
24852
25613
25719
26960
27423
27964
28383
28919
29229
29567
29726
30261
30346
30702
31053
31324
31445
31848
32108
32410
32758
33037
33150
33470
33680
33739
34280
34437
34537
34541
34826
35026
35156
35315
35375
35561
35595
35701
35813
36001
36067
36122
36243
36349
36454
36557
36628
36628
36796
36796
36796
36833
36915
36982
37023
37101
37140
37140
37355
37431
37510
37517
37637
37682
37682
37685
37685
37845
37942
37980
38039
38085
38156
38199
38215
38226
38229
38229
38248
38282
38329
38374
38374
38390
38484
38580
38606
38630
38658
38692
38727
38802
38858
38901
38941
38958
38969
39005
39130
39160
39182
39231
39256
39272
39278
39313
39325
39340
39354
39371
39376
39383
39427
39508
39572
39634
39702
39779
39789
39885
39956
40014
40080
40112
40159
40227
40286
40373
40461
40461
40510
40626
40687
40768
40833
40937
41032
41145
41268
41334
41425
41501
41633
41728
41814
41935
41975
42033
42159
42297
42463
42609
42795
42969
43035
43240
43403
43628
43851
44228
44443
44503
44706
44988
45278
45490
45716
45839
45966
46215
46498
46717
46980
47258
47388
47641
47901
48136
48366
48540
48753
48826
48952
49273
49484
49703
49927
50202
50456
50536
50678
50888
51070
51357
51595
51764
51848
52007
52147
52330
52330
52513
52586
52709
52909
53011
53105
53207
53332
53400
53489
53538
53584
53690
53775
53831
53938
53984
54062
54141
54278
54403
54483
54559
54595
54672
54750
54854
54891
54939
55008
55023
55059
55121
55174
55231
55265
55330
55335
55359
55384
55402
55420
55445
55473
55492
55514
55518
55540
55557
55575
55580
55604
55617
55646
55664
55680
55696
55707
55714
55733
55759
55770
55775
55827
55840
55847
55876
55876
55894
55917
55959
55959
55985
55985
55995
56016
56044
56069
56093
56103
56153
56177
56192
56226
56254
56290
56294
56322
56384
56454
56517
56572
56595
56676
56717
56779
56873
56943
57019
57144
57160
57242
57364
57492
57534
57612
57721
57793
57898
58037
58214
58312
58542
58730
58843
59015
59225
59370
59576
59745
59939
60122
60300
60563
60797
61162
61455
61755
61842
62063
62403
62718
63045
63355
63412
63484
63598
63819
64122
64575
65080
65486
65728
66275
66903
67743
68366
69130
70111
70761
71838
72977
74026
75119
76628
77963
79224
80841
82326
84050
85892
87716
88740
89861
91458
93272
93288
96531
98734
100521
101906
103902
105749
107957
109532
111592
113124
114220
115751
117158
118659
120216
122156
123485
124748
125937
127464
129021
130113
131586
132777
133578
134653
135889
136643
137853
139051
140224
140602
141499
142414
142762
143183
143439
143666
143871
144285
145008
145552
145996
146523
147154
147501
147985
148572
148933
149361
149810
150240
150458
150778
151013
151291
151563
151770
151941
152033
152142
152243
152363
152411
152448
152497
152511
152583
152660
152722
152822
152960
153007
153033
153148
153220
153260
153306
153375
153395
153423
153534
153626
153736
153840
153962
153982
153990
154094
154180
154283
154361
154487
154487
154487
154585
154712
154757
154800
154960
154960
154960
155072
155093
155128
155174
155191
155191
155191
155287
155309
155380
155429
155448
155466
155508
155540
155599
155627
155682
155688
155739
155764
155776
155801
155859
155891
155931
155940
155944
156040
156071
156124
156166
156196
156210
156250
156284
156307
156323
156363
156392
156397
156397
156397
156397
156414
156456
156487
156510
156552
156610
156649
156739
156739
156812
156864
156896
156911
157015
157032
157144
157171
157190
157218
157260
157289
157359
157387
157412
157431
157454
157499
157508
157542
157585
157603
157611
157633
157648
157660
157665
157725
157734
157745
157787
157797
157816
157841
157878
157887
157895
157951
157967
157998
158037
158056
158084
158107
158189
158183
158205
158245
158275
158300
158309
158381
158394
158471
158511
158602
158639
158678
158717
158826
158974
159070
159303
159516
159548
159649
159896
160252
160692
161004
161057
161290
162111
162926
163555
164190
164727
165358
165711
166191
166924
167739
168550
169448
169940
170152
170604
171246
171422
171519
171673
171857
171931
172205
172441
172716
172901
173047
173084
173146
173395
173659
173879
174073
174214
174214
174331
174582
175000
175353
175525
175893
175974
176039
176201
176409
176571
176743
176918
176983
177039
177093
177191
177255
177321
177321
177321
177321
177520
177602
177658
177716
177747
177782
177803
177827
177897
177932
177974
177974
177974
177974
177974
178141
178257
178295
178352
178373
178387
178418
178457
178513
178574
178611
178638
178648
178689
178745
178769
178809
178850
178873
178879
178899
178901
178901
178901
178905
178919
178922
178981
179010
179017
179131
179169
179203
179242
179267
179321
179328
179477
179597
179624
179674
179716
179716
179771
179835
179835
180086
180122
180174
180259
180347
180419
180520
180584
180615
180615
180688
180741
180784
180864
180864
180864
180864
181120
181178
181236
181465
181534
181574
181666
181725
181808
181912
181987
182033
182072
182149
182228
182324
182403
182528
182594
182643
182724
182793
182793
182979
183084
183221
183235
183265
183268
183272
183285
183358
183407
183445
183572
183687
183908
184038
184224
184360
184473
184587
184819
185086
185272
185393
185481
185552
185749
185930
186120
186393
186697
187037
187109
187442
187685
187966
188202
188506
188704
188820
189045
189343
189477
189710
190010
190254
190435
190643
191040
191247
191585
191967
191967
191967
192463
192906
193004
193250
193520
193520
193912
194163
194355
194614
195012
195298
195471
195631
195925
196182
196404
196751
196870
196992
197066
197240
197434
197608
197788
198023
198163
198244
198416
198543
198750
198876
199067
199188
199310
199386
199545
199690
199845
199994
200130
200202
200372
200469
200626
200729
200846
201014
201096
201212
201276
201503
201557
201750
201949
202026
202108
202199
202347
202509
202608
202756
202834
202966
203063
203167
203265
203395
203497
203574
203681
203829
203942
204094
204287
204392
204417
204510
204610
204724
204820
204982
205009
205039
205146
205229
205324
205391
205506
205541
205612
205612
205802
205830
205907
206073
206133
206145
206206
206273
206331
206414
206465
206504
206543
206603
206702
206743
206788
206879
206912
206943
207037
207084
207146
207190
207239
207262
207310
207399
207438
207460
207493
207511
207550
207559
207616
207627
207654
207715
207748
207766
207766
207819
207841
207866
207900
207900
207900
207900
207900
207993
208009
208034
208062
208084
208084
208084
208097
208289
208324
208324
208432
208435
208435
208502
208545
208552
208669
208669
208621
208627
208704
208721
208771
208771
208943
208971
208982
209011
209036
209056
209072
209083
209084
209107
209153
209181
209181
209215
209230
209246
209274
209308
209322
209340
209358
209362
209369
209390
209406
209436
209451
209451
NA
Albania
41.15330
20.16830
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
10
12
23
33
38
42
51
55
59
64
70
76
89
104
123
146
174
186
197
212
223
243
259
277
304
333
361
377
383
400
409
416
433
446
467
475
494
518
539
548
562
584
609
634
663
678
712
726
736
750
766
773
782
789
795
803
820
832
842
850
856
868
872
876
880
898
916
933
946
948
949
964
969
981
989
998
1004
1029
1050
1076
1099
1122
1137
1143
1164
1184
1197
1212
1232
1246
1263
1299
1341
1385
1416
1464
1521
1590
1672
1722
1788
1838
1891
1962
1995
2047
2114
2192
2269
2330
2402
2466
2535
2580
2662
2752
2819
2893
2964
3038
3106
3188
3278
3371
3454
3571
3667
3752
3851
3906
4008
4090
4171
4290
4358
4466
4570
4637
4763
4880
4997
5105
5197
5276
5396
5519
5620
5750
5889
6016
6151
6275
6411
6536
6676
6817
6971
7117
7260
7380
7499
7654
7812
7967
8119
8275
8427
8605
8759
8927
9083
9195
9279
9380
9513
9606
9728
9844
9967
10102
10255
10406
10553
10704
10860
11021
11185
11353
11520
11672
11816
11948
12073
12226
12385
12535
12666
12787
12921
13045
13153
13259
13391
13518
13649
13806
13965
14117
14266
14410
14568
14730
14899
15066
15231
15399
15570
15752
15955
16212
16501
16774
17055
17350
17651
17948
18250
18556
18858
19157
19445
19729
20040
20315
20634
20875
21202
21523
21904
22300
22721
23210
23705
24206
24731
25294
25801
26211
26701
27233
27830
28432
29126
29837
30623
31459
32196
32761
33556
34300
34944
35600
36245
36790
37625
38182
39014
39719
40501
41302
42148
42988
43683
44436
45188
46061
46863
47742
48530
49191
50000
50637
51424
52004
52542
53003
53425
53814
54317
54827
55380
55755
56254
56572
57146
57727
58316
58316
58991
59438
59623
60283
61008
61705
62378
63033
63595
63971
64627
65334
65994
66635
67216
67690
67982
68568
69238
69916
70655
71441
72274
72812
73691
74567
75454
76350
77251
78127
78992
79934
80941
81993
83082
84212
85336
86289
87528
88671
89776
90835
91987
93075
93850
94651
95726
96838
97909
99062
100246
101285
102306
103327
104313
105229
106215
107167
107931
108823
109674
110521
111301
112078
112897
113580
114209
114840
115442
116123
116821
117474
118017
118492
118938
119528
120022
120541
121200
121544
121847
122295
122767
123216
123641
124134
124419
124723
125157
125506
125842
126183
126531
126795
126936
127192
127509
127795
128155
128393
128518
128752
128959
129128
129307
129456
129594
129694
129842
129980
130114
130270
130409
130537
130606
130736
130859
130977
131085
131185
131238
131276
131327
131419
131510
131577
131666
131723
131753
131803
131845
131890
131939
131978
132015
132032
132071
132095
132118
132153
132176
132209
132215
132229
132244
132264
132285
132297
132309
132315
132337
132351
132360
132372
132374
132379
132384
132397
132415
132426
132437
132449
132459
132461
132469
132476
132481
132484
132488
132490
132490
132496
132497
132499
132506
132509
132512
132513
132514
132521
132523
132526
132534
132535
132537
132544
132557
132565
132580
132587
132592
132597
132608
132616
132629
132647
132665
132686
132697
132740
132763
132797
132828
132853
132875
132891
132922
132952
132999
133036
133081
133121
133146
133211
133310
133442
133591
133730
133912
133981
134201
134487
134761
135140
135550
135947
136147
136598
137075
137597
138132
138790
139324
139721
140521
141365
142253
143174
144079
144847
145333
146387
147369
148222
149117
150101
150997
151499
152239
153318
154316
155293
156162
157026
157436
158431
159423
160365
161324
162173
162953
163404
164276
165096
165864
166690
167354
167893
168188
168782
169462
170131
170778
171327
171794
171794
172618
173190
173723
174168
174643
174968
175163
175664
176172
176667
177108
177536
177971
178188
178804
179463
180029
180623
181252
181696
181960
182610
183282
183873
184340
184887
185300
185497
186222
186793
187363
187994
187994
189125
189355
190125
190815
191440
192013
192600
193075
193269
193856
194472
195021
195523
195988
195988
196611
197167
197776
198292
198732
199137
199555
199750
199945
200173
200639
201045
201402
201730
201902
202295
202641
202863
203215
203524
203787
203925
204301
204627
204928
205224
205549
205777
205897
206273
206616
206935
207221
207542
207709
207709
208352
208899
208899
210224
210224
210885
210885
212021
212021
213257
214905
214905
219694
220487
222664
224569
226598
228777
230940
232637
233654
236486
239129
241512
244182
246412
248070
248070
248859
251015
252577
254126
254126
255741
258543
258543
261240
261240
263172
263172
264624
264875
265716
266416
267020
267020
267551
268008
268304
268491
268940
269301
269601
269904
270164
270370
270455
270734
270947
271141
271141
271527
271563
271702
271825
271825
272030
272030
272210
272250
272337
272412
272479
272552
272621
272663
272689
272711
272804
272885
272961
273040
273088
273088
273146
273164
273257
273318
273387
273432
273432
273529
273608
273677
273759
273823
273870
273913
274000
274055
274108
274136
274191
274219
274219
274272
274320
274376
274429
274462
274504
274520
274535
274606
274606
274737
274791
274828
274828
274862
274929
275002
275055
275107
275167
275177
275191
275211
275266
275310
275341
275366
275372
275416
275440
275485
275534
275574
275615
275621
275688
275732
275732
275732
275838
275864
275881
275939
275985
276012
276048
276081
276101
276101
276101
276221
276221
276310
276342
276401
276415
276468
276518
276583
276638
276690
276731
276731
276821
276821
276821
277141
277141
277409
277444
277663
277940
278211
278504
278793
279077
279077
279167
280298
280851
281470
282141
282690
282690
282690
283811
284758
285731
286732
287984
288176
289391
290954
290954
293917
295243
296305
296732
298578
300058
301394
302767
303925
304890
305123
306789
308050
309278
310362
311381
312097
312375
313582
314561
315337
316145
316976
317514
317681
318638
319444
320086
320781
321345
321804
322125
322837
323282
323829
325241
325736
326077
326181
326787
327232
327607
327961
328299
328515
328571
329017
329352
329615
329862
330062
330193
330221
330283
330516
330687
330842
330948
331036
331053
331191
331295
331384
331459
331540
331583
331601
331715
331810
331861
331908
331953
331976
331987
332066
332129
332173
332221
332263
332285
332290
332337
332372
332410
332443
332472
332494
332503
332534
332555
332579
332598
332619
332638
332645
332673
332701
332719
332739
332754
332772
332776
332816
332847
332889
332911
332949
332966
332966
332969
332996
332996
333027
333046
333055
333058
333071
333088
333103
333125
333138
333156
333161
333197
333215
333233
333233
333246
333256
333257
333282
333293
333305
333316
333322
333330
333330
333338
333343
333360
333381
333391
333408
333413
333455
333472
333490
333491
333521
333533
333535
333567
333591
333613
333635
333635
333650
333653
333686
333708
333708
333731
333749
333749
333751
333751
333776
333776
333806
333806
333811
333812
333812
333818
333850
333887
333916
333947
333948
333995
333995
334018
334018
334029
334037
334037
334064
334084
334084
334084
334097
334101
334101
334113
334124
334135
334144
334153
334157
334157
334167
334177
334187
334203
334204
334211
334211
334211
334222
334229
334229
334234
334255
334255
334264
334264
334273
334291
334305
334314
334315
334336
334336
334345
334356
334373
334378
334380
334391
334408
334408
334427
334427
334427
334427
334427
334443
334457
NA
Algeria
28.03390
1.65960
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
3
5
12
12
17
17
19
20
20
20
24
26
37
48
54
60
74
87
90
139
201
230
264
302
367
409
454
511
584
716
847
986
1171
1251
1320
1423
1468
1572
1666
1761
1825
1914
1983
2070
2160
2268
2418
2534
2629
2718
2811
2910
3007
3127
3256
3382
3517
3649
3848
4006
4154
4295
4474
4648
4838
4997
5182
5369
5558
5723
5891
6067
6253
6442
6629
6821
7019
7201
7377
7542
7728
7918
8113
8306
8503
8697
8857
8997
9134
9267
9394
9513
9626
9733
9831
9935
10050
10154
10265
10382
10484
10589
10698
10810
10919
11031
11147
11268
11385
11504
11631
11771
11920
12076
12248
12445
12685
12968
13273
13571
13907
14272
14657
15070
15500
15941
16404
16879
17348
17808
18242
18712
19195
19689
20216
20770
21355
21948
22549
23084
23691
24278
24872
25484
26159
26764
27357
27973
28615
29229
29831
30394
30950
31465
31972
32504
33055
33626
34155
34693
35160
35712
36204
36699
37187
37664
38133
38583
39025
39444
39847
40258
40667
41068
41460
41858
42228
42619
43016
43403
43781
44146
44494
44833
45158
45469
45773
46071
46364
46653
46938
47216
47488
47752
48007
48254
48496
48734
48966
49194
49413
49623
49826
50023
50214
50400
50579
50754
50914
51067
51213
51368
51530
51690
51847
51995
52136
52270
52399
52520
52658
52804
52940
53072
53325
53399
53584
53777
53998
54203
54402
54616
54829
55081
55357
55630
55880
56143
56419
56706
57026
57332
57651
57942
58272
58574
58979
59527
60169
60800
61381
62051
62693
63446
64257
65108
65975
66819
67679
68589
69591
70629
71652
72755
73774
74862
75867
77000
78025
79110
80168
81212
82221
83199
84152
85084
85927
86730
87502
88252
88825
89416
90014
90579
91121
91638
92102
92597
93065
93507
93933
94371
94781
95203
95659
96069
96549
97007
97441
97857
98249
98631
98988
99311
99610
99897
100159
100408
100645
100873
101120
101382
101657
101913
102144
102369
102641
102860
103127
103381
103611
103833
104092
104341
104606
104852
105124
105369
105596
105854
106097
106359
106610
106887
107122
107339
107578
107841
108116
108381
108629
108629
109088
109313
109559
109782
110049
110303
110513
110711
110894
111069
111247
111418
111600
111764
111917
112094
112279
112461
112622
112805
112960
113092
113255
113430
113593
113761
113948
114104
114234
114382
114543
114681
114851
115008
115143
115265
115410
115540
115688
115842
115970
116066
116157
116255
116349
116438
116543
116657
116750
116836
116946
117061
117192
117304
117429
117524
117622
117739
117879
118004
118116
118251
118378
118516
118645
118799
118975
119142
119323
119486
119642
119805
119992
120174
120363
120562
120736
120922
121112
121344
121580
121866
122108
122311
122522
122717
122999
123272
123473
123692
123900
124104
124288
124483
124682
124889
125059
125194
125311
125485
125693
125896
126156
126434
126651
126860
127107
127361
127646
127926
128198
128456
128725
128913
129218
129640
129976
130361
130681
130958
131283
131647
132034
132355
132727
133070
133388
133742
134115
134458
134840
135219
135586
135821
136294
136679
137049
137403
137772
138113
138465
138840
139229
139626
140075
140550
141007
141471
141966
142447
143032
143652
144483
145296
146064
146942
147883
148797
149906
151103
152210
153309
154486
155784
157005
158213
159563
160868
162155
163660
165204
167131
168668
170189
171392
172564
173922
175229
176724
178013
179216
180356
181376
182368
183347
184191
185042
185902
186655
187258
187968
188663
189384
190078
190656
191171
191583
192089
192626
193171
193674
194186
194671
195162
195574
196080
196527
196915
197308
197659
198004
198313
198645
198962
199275
199560
199822
200068
200301
200528
200770
200989
201224
201425
201600
201766
201948
202122
202283
202449
202574
202722
202877
203045
203198
203359
203517
203657
203789
203915
204046
204171
204276
204388
204490
204597
204695
204790
204900
205005
205106
205199
205286
205364
205453
205529
205599
205683
205750
205822
205903
205990
206069
206160
206270
206358
206452
206566
206649
206754
206878
206995
207079
207156
207254
207385
207509
207624
207764
207873
207970
208104
208245
208380
208532
208695
208839
208952
209111
209283
209463
209624
209817
209980
210152
210344
210531
210723
210921
211112
211297
211469
211662
211859
212047
212224
212434
212652
212848
213058
213288
213533
213745
214044
214330
214592
214835
215145
215430
215723
216098
216376
216637
216930
217265
217647
218037
218432
218818
219159
219532
219953
220415
220825
221316
221742
222157
222639
223196
223806
224383
224979
225484
226057
226749
227559
228918
230470
232325
234536
236670
238885
241406
243568
245698
247568
249310
250774
252117
253520
254885
255836
256806
257598
257976
258478
259088
259673
260191
260723
261226
261752
262165
262570
262994
263369
263685
263936
264054
264201
264365
264488
264603
264706
264778
264855
264936
265010
265079
265130
265186
265227
265265
265297
265323
265346
265366
265391
265410
265432
265457
265478
265496
265511
265524
265539
265550
265562
265573
265585
265599
265612
265621
265629
265641
265651
265662
265671
265679
265684
265691
265694
265699
265705
265707
265714
265720
265724
265727
265730
265731
265733
265738
265739
265739
265741
265746
265746
265754
265761
265761
265767
265771
265772
265773
265776
265779
265780
265782
265782
265782
265782
265786
265791
265794
265798
265800
265804
265806
265808
265814
265816
265818
265823
265828
265834
265841
265847
265851
265854
265855
265860
265862
265864
265870
265873
265873
265877
265884
265887
265889
265889
265889
265897
265900
265904
265909
265920
265925
265925
265927
265937
265943
265952
265964
265968
265971
265975
265985
265993
266006
266015
266025
266030
266038
266049
266062
266073
266087
266105
266115
266128
266173
266173
266181
266202
266228
266246
266257
266274
266303
266328
266356
266392
266424
266445
266487
266542
266591
266654
266700
266772
266839
266916
267010
267096
267194
267287
267374
267454
267546
267657
267777
267902
268033
268141
268254
268356
268478
268584
268718
268866
269008
269141
269269
269381
269473
269556
269650
269731
269805
269894
269971
270043
270097
270145
270175
270194
270235
270272
270304
270359
270405
270426
270443
270461
270476
270489
270507
270522
270532
270539
270551
270551
270570
270584
270599
270606
270609
270612
270612
270619
270625
270631
270637
270641
270649
270654
270662
270668
270673
270676
270679
270682
270690
270693
270697
270701
270701
270707
270713
270716
270722
270722
270734
270734
270740
270757
270766
270768
270769
270771
270771
270783
270788
270800
270810
270817
270826
270829
270836
270838
270839
270840
270847
270856
270862
270873
270881
270891
270906
270917
270924
270929
270939
270952
270969
270981
270996
270996
271011
271023
271028
271035
271041
271050
271057
271061
271061
271079
271082
271090
271096
271100
271102
271107
271113
271122
271128
271135
271140
271146
271146
271147
271149
271156
271156
271156
271168
271174
271179
271182
271186
271190
271193
271194
271198
271198
271202
271208
271217
271223
271228
271229
271229
271230
271236
271244
271250
271254
271254
271255
271262
271268
271277
271286
271287
271287
271287
271292
271296
271307
271316
271328
271335
271346
271354
271360
271364
271369
271369
271376
271376
271378
271385
271386
271394
271394
271394
271395
271399
271403
271406
271406
271409
271409
271409
271409
271421
271424
271424
271425
271425
271426
271428
271431
271432
271436
271439
271440
271440
271441
271448
271463
271469
271469
271477
271477
271490
271494
271496
NA
Andorra
42.50630
1.52180
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
39
39
53
75
88
113
133
164
188
224
267
308
334
370
376
390
428
439
466
501
525
545
564
583
601
601
638
646
659
673
673
696
704
713
717
717
723
723
731
738
738
743
743
743
745
745
747
748
750
751
751
752
752
754
755
755
758
760
761
761
761
761
761
761
762
762
762
762
762
763
763
763
763
764
764
764
765
844
851
852
852
852
852
852
852
852
852
853
853
853
853
854
854
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
855
858
861
862
877
880
880
880
884
884
889
889
897
897
897
907
907
918
922
925
925
925
937
939
939
944
955
955
955
963
963
977
981
989
989
989
1005
1005
1024
1024
1045
1045
1045
1060
1060
1098
1098
1124
1124
1124
1176
1184
1199
1199
1215
1215
1215
1261
1261
1301
1301
1344
1344
1344
1438
1438
1483
1483
1564
1564
1564
1681
1681
1753
1753
1836
1836
1836
1966
1966
2050
2050
2110
2110
2110
2370
2370
2568
2568
2696
2696
2696
2995
2995
3190
3190
3377
3377
3377
3623
3623
3811
3811
4038
4038
4038
4325
4410
4517
4567
4665
4756
4825
4888
4910
5045
5135
5135
5319
5383
5437
5477
5567
5616
5725
5725
5872
5914
5951
6018
6066
6142
6207
6256
6304
6351
6428
6534
6610
6610
6712
6745
6790
6842
6904
6955
7005
7050
7084
7127
7162
7190
7236
7288
7338
7382
7382
7446
7466
7519
7560
7577
7602
7633
7669
7699
7756
7806
7821
7875
7919
7983
8049
8117
8166
8192
8249
8308
8348
8348
8489
8586
8586
8586
8682
8818
8868
8946
9038
9083
9083
9194
9308
9379
9416
9499
9549
9596
9638
9716
9779
9837
9885
9937
9972
10017
10070
10137
10172
10206
10251
10275
10312
10352
10391
10427
10463
10503
10538
10555
10583
10610
10645
10672
10699
10712
10739
10775
10799
10822
10849
10866
10889
10908
10948
10976
10998
11019
11042
11069
11089
11130
11130
11199
11228
11266
11289
11319
11360
11393
11431
11481
11517
11545
11591
11638
11687
11732
11809
11850
11888
11944
12010
12053
12115
12174
12231
12286
12328
12363
12409
12456
12497
12545
12581
12614
12641
12641
12712
12771
12805
12805
12874
12917
12942
13007
13024
13060
13083
13121
13148
13198
13232
13232
13282
13295
13316
13340
13363
13390
13406
13423
13429
13447
13470
13470
13510
13510
13510
13555
13569
13569
13569
13569
13569
13569
13569
13664
13671
13682
13693
13693
13693
13727
13729
13744
13752
13758
13758
13758
13777
13781
13791
13805
13813
13813
13813
13826
13828
13836
13839
13842
13842
13842
13864
13864
13873
13877
13882
13882
13882
13882
13900
13911
13918
13918
13918
13918
13918
13991
14021
14050
14075
14075
14075
14155
14167
14167
14239
14273
14273
14273
14359
14379
14379
14464
14498
14498
14498
14577
14586
14586
14655
14678
14678
14678
14747
14766
14797
14809
14836
14836
14836
14836
14873
14891
14908
14924
14924
14924
14954
14960
14976
14981
14988
14988
14988
15002
15003
15014
15016
15025
15025
15025
15032
15033
15046
15052
15055
15055
15055
15069
15070
15070
15078
15083
15083
15083
15096
15099
15108
15113
15124
15124
15124
15140
15140
15153
15156
15167
15167
15167
15189
15192
15209
15222
15222
15222
15222
15267
15271
15284
15288
15291
15291
15291
15307
15307
15314
15326
15338
15338
15338
15367
15369
15382
15382
15404
15404
15404
15425
15425
15462
15505
15516
15516
15516
15516
15516
15572
15618
15618
15618
15618
15705
15717
15744
15744
15819
15819
15819
15907
15929
15972
16035
16086
16086
16086
16299
16342
16426
16566
16712
16712
16712
16712
17115
17426
17658
18010
18010
18010
18631
18815
18815
19272
19440
19440
19440
19440
20136
20136
20549
20549
20549
20549
21062
21062
21372
21571
21730
21730
21730
22332
22540
22823
23122
23740
23740
23740
24502
24802
25289
25289
26408
26408
26408
27983
28542
28899
28899
29888
29888
29888
29888
29888
29888
32201
33025
33025
33025
33025
34701
35028
35028
35556
35556
35556
35958
35958
36315
36470
36599
36599
36599
36808
36808
36989
37074
37140
37140
37140
37277
37361
37452
37522
37589
37589
37589
37589
37820
37901
37958
37999
37999
37999
37999
38165
38249
38342
38434
38434
38434
38620
38710
38794
38794
38794
38794
38794
38794
38794
38794
39234
39234
39234
39234
39234
39234
39713
39713
39713
39713
39713
39713
39713
40024
40024
40024
40024
40024
40024
40024
40024
40328
40328
40328
40328
40328
40328
40709
40709
40709
40709
40709
40709
40709
41013
41013
41013
41013
41013
41013
41013
41013
41349
41349
41349
41349
41349
41349
41717
41717
41717
41717
41717
41717
41717
41717
42156
42156
42156
42156
42156
42156
42572
42572
42572
42572
42572
42572
42572
42894
42894
42894
42894
42894
42894
42894
42894
42894
43067
43067
43067
43067
43067
43224
43224
43224
43224
43224
43224
43224
43449
43449
43449
43449
43449
43449
43449
43774
43774
43774
43774
43774
43774
43774
43774
43774
44177
44177
44177
44177
44177
44671
44671
44671
44671
44671
44671
44671
44671
44671
44671
44671
44671
45061
45061
45061
45326
45326
45326
45326
45326
45326
45326
45508
45508
45508
45508
45508
45508
45793
45793
45793
45793
45793
45793
45793
45899
45899
45899
45899
45899
45899
45899
45975
45975
45975
45975
45975
45975
45975
46027
46027
46027
46027
46027
46027
46027
46027
46027
46027
46027
46027
46027
46027
46113
46113
46113
46113
46113
46113
46113
46147
46147
46147
46147
46147
46147
46147
46147
46147
46147
46147
46147
46147
46147
46227
46227
46227
46227
46227
46227
46227
46227
46275
46275
46275
46275
46275
46275
46366
46366
46366
46366
46366
46366
46366
46449
46449
46449
46449
46449
46449
46449
46535
46535
46535
46535
46535
46535
46535
46588
46588
46588
46588
46588
46588
46588
46664
46664
46664
46664
46664
46664
46664
46824
46824
46824
46824
46824
46824
46824
46824
46824
46824
46824
46824
46824
46824
47219
47219
47219
47219
47219
47219
47219
47446
47446
47446
47446
47446
47446
47446
47606
47606
47606
47606
47606
47606
47686
47686
47686
47686
47686
47686
47686
47686
47751
47751
47751
47751
47751
47751
47751
47751
47781
47781
47781
47781
47781
47781
47781
47781
47781
47781
47781
47781
47781
47781
47820
47820
47820
47820
47820
47820
47820
47820
47820
47839
47839
47839
47839
47839
47839
47850
47850
47850
47850
47850
47850
47860
47860
47860
47860
47860
47860
47860
47866
47866
47866
47866
47866
47866
47866
47866
47866
47866
47866
47866
47866
47875
47875
47875
47875
47875
47875
47875
47890
47890
NA
Angola
-11.20270
17.87390
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
2
2
3
3
3
4
4
5
7
7
7
8
8
8
10
14
16
17
19
19
19
19
19
19
19
19
19
19
24
24
24
24
25
25
25
25
26
27
27
27
27
30
35
35
35
36
36
36
43
43
45
45
45
45
48
48
48
48
50
52
52
58
60
61
69
70
70
71
74
81
84
86
86
86
86
86
86
88
91
92
96
113
118
130
138
140
142
148
155
166
172
176
183
186
189
197
212
212
259
267
276
284
291
315
328
346
346
346
386
386
396
458
462
506
525
541
576
607
638
687
705
749
779
812
851
880
916
932
950
1000
1078
1109
1148
1164
1199
1280
1344
1395
1483
1538
1572
1672
1679
1735
1762
1815
1852
1879
1906
1935
1966
2015
2044
2068
2134
2171
2222
2283
2332
2415
2471
2551
2624
2654
2729
2777
2805
2876
2935
2965
2981
3033
3092
3217
3279
3335
3388
3439
3569
3675
3789
3848
3901
3991
4117
4236
4363
4475
4590
4672
4718
4797
4905
4972
5114
5211
5370
5402
5530
5725
5725
5958
6031
6246
6366
6488
6680
6846
7096
7222
7462
7622
7829
8049
8338
8582
8829
9026
9381
9644
9871
10074
10269
10558
10805
11035
11228
11577
11813
12102
12223
12335
12433
12680
12816
12953
13053
13228
13374
13451
13615
13818
13922
14134
14267
14413
14493
14634
14742
14821
14920
15008
15087
15103
15139
15251
15319
15361
15493
15536
15591
15648
15729
15804
15925
16061
16161
16188
16277
16362
16407
16484
16562
16626
16644
16686
16802
16931
17029
17099
17149
17240
17296
17371
17433
17553
17568
17608
17642
17684
17756
17864
17974
18066
18156
18193
18254
18343
18425
18613
18679
18765
18875
18926
19011
19093
19177
19269
19367
19399
19476
19553
19580
19672
19723
19782
19796
19829
19900
19937
19996
20030
20062
20086
20112
20163
20210
20261
20294
20329
20366
20381
20389
20400
20452
20478
20499
20519
20548
20584
20640
20695
20759
20782
20807
20854
20882
20923
20981
21026
21055
21086
21108
21114
21161
21205
21265
21323
21380
21407
21446
21489
21558
21642
21696
21733
21757
21774
21836
21914
21961
22031
22063
22132
22182
22311
22399
22467
22579
22631
22717
22885
23010
23108
23242
23331
23457
23549
23697
23841
23951
24122
24300
24389
24518
24661
24883
25051
25279
25492
25609
25710
25942
26168
26431
26652
26815
26993
27133
27284
27529
27921
28201
28477
28740
28875
29146
29405
29695
30030
30354
30637
30787
31045
31438
31661
31909
32149
32441
32623
32933
33338
33607
33944
34180
34366
34551
34752
34960
35140
35307
35594
35772
35854
36004
36115
36325
36455
36600
36705
36790
36921
37094
37289
37467
37604
37678
37748
37874
38002
38091
38371
38528
38556
38613
38682
38849
38965
39089
39172
39230
39300
39375
39491
39593
39791
39881
39958
40055
40138
40327
40530
40631
40707
40805
40906
41061
41227
41405
41629
41736
41780
41879
42110
42288
42486
42646
42777
42815
42970
43070
43158
43269
43487
43592
43662
43747
43890
43998
44174
44328
44534
44617
44739
44972
45175
45325
45583
45817
45945
46076
46340
46539
46726
46929
47079
47168
47331
47544
47781
48004
48261
48475
48656
48790
49114
49349
49628
49943
50348
50446
50738
51047
51407
51827
52208
52307
52307
52644
52968
53387
53840
54280
54795
55121
55583
56040
56583
56583
58076
58603
58943
58943
59895
60448
60803
61023
61245
61378
61580
61794
62143
62385
62606
62789
62842
63012
63197
63340
63567
63691
63775
63861
63930
64033
64126
64226
64301
64374
64433
64458
64487
64533
64583
64612
64654
64674
64724
64762
64815
64857
64875
64899
64913
64913
64940
64968
64985
64997
65011
65024
65033
65061
65080
65105
65130
65139
65144
65155
65168
65183
65208
65223
65244
65259
65259
65301
65332
65346
65371
65397
65404
65404
65431
65565
65648
65760
65868
65938
66086
66566
67199
68362
70221
71142
71752
71752
76787
78475
79871
81593
82398
82920
83764
84666
86636
87625
88775
89251
89718
90316
91148
91907
92581
93302
93524
93694
93974
94275
94779
95220
95676
95902
96582
97263
97594
97812
97901
98029
98057
98076
98116
98226
98267
98319
98340
98351
98364
98409
98424
98453
98474
98501
98514
98514
98514
98555
98568
98585
98605
98617
98638
98658
98671
98698
98701
98701
98701
98701
98741
98746
98746
98746
98796
98796
98806
98806
98829
98855
98855
98855
98909
98927
98931
98956
98985
99003
99003
99003
99003
99010
99058
99058
99081
99102
99106
99115
99115
99138
99138
99169
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99194
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99287
99433
99527
99527
99527
99527
99527
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
99761
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101320
101600
101901
101901
101901
102209
102209
102209
102209
102301
102301
102301
102301
102301
102301
102301
102301
102301
102301
102301
102301
102301
102301
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
102636
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
103131
104491
104491
104491
104491
104491
104491
104491
104676
104676
104676
104676
104676
104750
104750
104808
104808
104808
104808
104808
104808
104808
104946
104946
104946
104946
104946
104946
104946
104973
104973
104973
104973
104973
104973
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105095
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105184
105205
105205
105205
105205
105205
105255
105255
105277
105277
105277
105277
105277
105277
105277
105288
105288
Handling Missing Values and Data Consistency
This step addresses missing or inconsistent values in the dataset. Missing values in the province column are replaced with "None" to maintain consistent categorical values. Any missing case counts are replaced with 0 to avoid errors in later calculations. The dataset is then sorted by country, province, and date to maintain a logical chronological structure.
# Handle missing or inconsistent values
df_tidy <- df_tidy %>%
arrange (country, province, date) %>%
group_by (country, province) %>%
mutate (
daily_cases = confirmed_cases - lag (confirmed_cases, default = 0 ),
daily_cases = if_else (daily_cases < 0 , 0 L, daily_cases) # replace negatives with 0
) %>%
ungroup ()
df_tidy |>
head (n = 5 ) |>
gt ()
NA
Afghanistan
33.93911
67.70995
2020-01-22
0
0
NA
Afghanistan
33.93911
67.70995
2020-01-23
0
0
NA
Afghanistan
33.93911
67.70995
2020-01-24
0
0
NA
Afghanistan
33.93911
67.70995
2020-01-25
0
0
NA
Afghanistan
33.93911
67.70995
2020-01-26
0
0
Country-Level Summary of COVID-19 Cases
This analysis aggregates the tidy dataset to produce summary statistics for each country. The total confirmed cases, maximum daily cases, and average daily cases are calculated using dplyr functions. The resulting summary table is sorted by total cases and displayed using the gt package for clearer presentation and formatted numeric values.
# Country-level summary using daily cases
country_summary <- df_tidy %>%
group_by (country) %>%
summarise (
total_cases = sum (confirmed_cases, na.rm = TRUE ),
max_daily_cases = max (confirmed_cases, na.rm = TRUE ),
avg_daily_cases = round (mean (confirmed_cases, na.rm = TRUE ))
) %>%
arrange (desc (total_cases))
country_summary |>
gt () |>
tab_header (
title = "Total Confirmed Cases per Country"
) |>
cols_label (
country = "Country" ,
total_cases = "Total Cases" ,
max_daily_cases = "Max Daily Cases" ,
avg_daily_cases = "Average Daily Cases"
) |>
fmt_number (
columns = c (total_cases, max_daily_cases, avg_daily_cases),
decimals = 0 ,
use_seps = TRUE
)
Country
Total Cases
Max Daily Cases
Average Daily Cases
US
103,802,702
1,354,505
90,816
India
44,690,738
414,188
39,100
France
39,866,718
501,635
2,907
Germany
38,249,060
484,345
33,464
Brazil
37,076,053
287,149
32,437
Japan
33,320,438
260,999
29,152
Korea, South
30,615,522
621,317
26,785
Italy
25,603,510
229,122
22,400
United Kingdom
24,658,705
847,371
1,438
Russia
22,075,858
202,211
19,314
Turkey
17,042,722
823,225
14,911
Spain
13,770,429
372,766
12,048
Vietnam
11,526,994
454,212
10,085
Australia
11,399,460
92,264
1,247
Argentina
10,044,957
139,853
8,788
Taiwan*
9,970,937
128,954
8,723
Netherlands
8,712,835
380,388
1,525
Iran
7,572,311
50,228
6,625
Mexico
7,483,444
109,895
6,547
Indonesia
6,738,225
64,718
5,895
Poland
6,444,960
57,659
5,639
Colombia
6,359,093
35,575
5,564
Austria
5,961,143
64,038
5,215
Ukraine
5,711,929
79,325
4,997
Portugal
5,570,473
77,281
4,874
Greece
5,548,487
367,629
4,854
Chile
5,192,286
41,651
4,543
Malaysia
5,044,718
33,406
4,414
China
4,903,524
76,991
126
Israel
4,803,824
243,295
4,203
Belgium
4,739,365
133,480
4,146
Thailand
4,728,182
47,149
4,137
Czechia
4,618,256
67,107
4,040
Canada
4,617,095
39,625
252
Peru
4,487,553
67,101
3,926
Switzerland
4,413,911
89,462
3,862
Philippines
4,077,452
38,867
3,567
South Africa
4,067,067
37,875
3,558
Denmark
3,451,036
55,120
1,006
Romania
3,346,046
40,018
2,927
Sweden
2,699,339
138,985
2,362
Slovakia
2,667,551
33,633
2,334
Serbia
2,500,142
36,737
2,187
Iraq
2,465,545
13,515
2,157
New Zealand
2,236,114
42,699
652
Singapore
2,235,294
39,252
1,956
Hungary
2,196,804
45,047
1,922
Bangladesh
2,037,871
16,230
1,783
Georgia
1,827,537
26,524
1,599
Jordan
1,746,997
25,502
1,528
Ireland
1,704,502
43,199
1,491
Pakistan
1,577,411
12,073
1,380
Kazakhstan
1,498,668
66,121
1,311
Norway
1,479,506
26,109
1,294
Finland
1,463,644
50,889
1,281
Slovenia
1,331,707
23,332
1,165
Lithuania
1,307,448
15,412
1,144
Bulgaria
1,297,523
12,399
1,135
Morocco
1,272,490
12,039
1,113
Croatia
1,269,326
11,812
1,111
Guatemala
1,238,247
9,946
1,083
Lebanon
1,232,828
10,760
1,079
Costa Rica
1,209,725
55,406
1,058
Bolivia
1,194,277
23,611
1,045
Tunisia
1,151,126
27,340
1,007
Cuba
1,112,643
9,907
973
Ecuador
1,057,121
17,670
925
United Arab Emirates
1,053,213
4,471
921
Uruguay
1,034,303
13,612
905
Panama
1,031,731
19,722
903
Mongolia
1,007,900
24,556
882
Nepal
1,001,154
10,052
876
Belarus
994,037
11,170
870
Latvia
976,255
11,992
854
Saudi Arabia
830,127
5,928
726
Azerbaijan
828,825
7,779
725
Paraguay
808,401
59,361
707
Bahrain
710,693
8,173
622
West Bank and Gaza
703,228
30,356
615
Sri Lanka
672,039
11,366
588
Kuwait
663,860
6,913
581
Dominican Republic
660,790
7,439
578
Cyprus
650,685
15,386
569
Burma
633,950
7,083
555
Estonia
615,433
8,438
538
Moldova
611,140
10,147
535
Venezuela
552,162
4,418
483
Egypt
515,759
5,516
451
Libya
507,187
5,694
444
Ethiopia
500,116
5,185
438
Qatar
495,090
4,206
433
Honduras
472,250
12,890
413
Armenia
447,308
4,388
391
Bosnia and Herzegovina
401,729
5,254
351
Oman
399,449
6,146
349
North Macedonia
346,852
2,332
303
Zambia
343,135
5,555
300
Kenya
342,937
3,749
300
Albania
334,457
4,789
293
Botswana
329,758
41,576
289
Luxembourg
317,367
5,497
278
Mauritius
296,042
30,006
259
Montenegro
288,808
2,960
253
Brunei
279,661
7,380
245
Kosovo
273,312
4,397
239
Algeria
271,496
2,521
238
Nigeria
266,598
6,158
233
Zimbabwe
264,276
9,185
231
Uzbekistan
251,247
1,478
220
Mozambique
233,214
4,947
204
Laos
218,023
3,915
191
Afghanistan
209,451
3,243
183
Iceland
209,137
7,408
183
Kyrgyzstan
206,708
11,505
181
El Salvador
201,785
12,677
177
Trinidad and Tobago
189,918
1,259
166
Maldives
185,738
2,838
163
Ghana
171,229
2,521
150
Namibia
171,156
4,210
150
Uganda
170,544
21,324
149
Jamaica
154,416
1,968
135
Cambodia
138,719
1,130
121
Rwanda
133,194
3,072
117
Cameroon
124,392
9,668
109
Malta
117,610
1,677
103
Barbados
106,798
1,329
93
Angola
105,288
5,035
92
Congo (Kinshasa)
95,749
4,481
84
Senegal
88,926
1,722
78
Malawi
88,707
1,316
78
Cote d'Ivoire
88,263
2,858
77
Suriname
82,467
1,404
72
Eswatini
74,267
1,642
65
Guyana
73,075
1,186
64
Belize
70,757
1,517
62
Fiji
68,898
1,854
60
Madagascar
67,889
2,295
59
Sudan
63,829
1,284
56
Mauritania
63,668
1,211
56
Cabo Verde
63,244
1,469
55
Bhutan
62,627
2,291
55
Syria
57,467
905
50
Burundi
53,631
4,710
47
Seychelles
50,665
2,068
44
Gabon
48,981
1,871
43
Andorra
47,890
2,313
42
Papua New Guinea
46,825
1,543
41
Tanzania
42,906
24,307
38
Togo
39,396
1,002
34
Guinea
38,267
534
33
Bahamas
37,491
1,497
33
Lesotho
34,790
6,925
30
Haiti
34,202
284
30
Mali
33,062
1,217
29
Saint Lucia
30,004
722
26
Benin
27,999
2,566
24
Somalia
27,324
1,066
24
Congo (Brazzaville)
25,087
1,188
22
Solomon Islands
24,575
3,063
22
Micronesia
23,948
3,652
21
San Marino
23,616
491
21
Timor-Leste
23,419
532
20
Burkina Faso
22,056
1,005
19
Liechtenstein
21,432
349
19
Grenada
19,680
902
17
South Sudan
18,368
503
16
Tajikistan
17,786
407
16
Equatorial Guinea
17,229
1,750
15
Tonga
16,810
832
15
Samoa
16,607
1,166
15
Monaco
16,121
520
14
Dominica
15,760
895
14
Djibouti
15,690
415
14
Nicaragua
15,655
516
14
Marshall Islands
15,649
3,130
14
Central African Republic
15,368
4,044
13
Gambia
12,598
587
11
Vanuatu
12,014
616
11
Yemen
11,945
287
10
Eritrea
10,189
282
9
Saint Vincent and the Grenadines
9,589
2,723
8
Niger
9,508
301
8
Antigua and Barbuda
9,106
468
8
Comoros
9,008
275
8
Guinea-Bissau
8,960
305
8
Liberia
8,090
447
7
Sierra Leone
7,760
192
7
Chad
7,679
596
7
Saint Kitts and Nevis
6,597
238
6
Sao Tome and Principe
6,281
319
5
Palau
5,991
371
5
Nauru
5,247
1,241
5
Kiribati
5,014
1,491
4
Tuvalu
2,805
793
2
Summer Olympics 2020
865
112
1
Diamond Princess
712
99
1
Winter Olympics 2022
535
72
0
Holy See
29
7
0
Antarctica
11
11
0
MS Zaandam
9
7
0
Korea, North
1
1
0
Interactive Global Map of Average Daily COVID-19 Cases
This step creates an interactive choropleth map that visualizes the global distribution of COVID-19 average daily cases by country. Country names are converted to ISO-3 country codes to enable geographic mapping. The map uses a reversed yellow-to-red color gradient where darker red indicates higher average daily case counts. Hovering over a country displays its name along with the average and maximum daily confirmed cases.
library (dplyr)
library (plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
library (countrycode)
country_map_data <- df_tidy %>%
group_by (country) %>%
summarise (
avg_daily_cases = round (mean (confirmed_cases, na.rm = TRUE )),
max_daily_cases = max (confirmed_cases, na.rm = TRUE )
) %>%
ungroup () %>%
mutate (
iso3 = countrycode (country, "country.name" , "iso3c" )
) %>%
filter (! is.na (iso3))
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `iso3 = countrycode(country, "country.name", "iso3c")`.
Caused by warning:
! Some values were not matched unambiguously: Diamond Princess, Kosovo, Micronesia, MS Zaandam, Summer Olympics 2020, Winter Olympics 2022
To fix unmatched values, please use the `custom_match` argument. If you think the default matching rules should be improved, please file an issue at https://github.com/vincentarelbundock/countrycode/issues
plot_ly (
data = country_map_data,
type = "choropleth" ,
locations = ~ iso3,
z = ~ avg_daily_cases,
text = ~ paste (
"Country:" , country,
"<br>Average Daily Cases:" , format (avg_daily_cases, big.mark = "," , scientific = FALSE ),
"<br>Max Daily Cases:" , format (max_daily_cases, big.mark = "," , scientific = FALSE )
),
hoverinfo = "text" ,
colorscale = "YlOrRd_r" ,
marker = list (line = list (color = "white" , width = 0.3 )),
colorbar = list (
title = "Avg Daily Cases" ,
tickformat = ","
)
) %>%
layout (
title = "Global COVID-19 Average Daily Cases by Country" ,
geo = list (
showframe = FALSE ,
showcoastlines = TRUE ,
coastlinecolor = "gray" ,
projection = list (type = "natural earth" )
)
)
Time Series for Daily COVID-19 Confirmed Cases in the USA
I have filtered for the USA and created a time series plot of daily confirmed cases below.
Attaching package: 'scales'
The following object is masked from 'package:purrr':
discard
The following object is masked from 'package:readr':
col_factor
# Filter for USA daily cases
usa_data <- df_tidy %>%
filter (country == "US" ) %>%
group_by (date) %>%
summarise (
daily_cases = sum (confirmed_cases, na.rm = TRUE )
) %>%
arrange (date)
ggplot (usa_data, aes (x = date, y = daily_cases)) +
geom_line (color = "skyblue" , size = 1 ) +
scale_y_continuous (labels = comma) +
labs (
title = "Daily COVID-19 Confirmed Cases in the USA" ,
x = "Date" ,
y = "Number of Cases" ,
caption = "Data Source: Johns Hopkins University CSSE"
) +
theme_minimal (base_size = 14 ) +
theme (
plot.title = element_text (face = "bold" , hjust = 0.5 ),
axis.text.x = element_text (angle = 45 , hjust = 1 )
)
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Conclusion
This project transformed a wide-format global COVID-19 dataset into a tidy structure using tidyr and dplyr , making the data easier to analyze and visualize. After cleaning and standardizing the variables, summary statistics were generated to examine country-level trends in confirmed cases. An interactive choropleth map was then created to visualize average daily cases across countries, highlighting regions with higher case levels. Overall, the analysis demonstrates how tidy data principles support clearer insights and more effective visualization of global health data.
Reference
OpenAI. (2026, March 8). ChatGPT conversation with K. M. Qaiduzzaman on tidying and visualizing global COVID-19 data in R [Large language model]. OpenAI. https://chat.openai.com/