library(magrittr)
library(gpairs)
library(ggplot2)
library(ggmap)
library(directlabels)
load(file = "dataList.RData")
## Extract main dataset
maindat <- dataList[[2]]
## Fix date
maindat$date <- maindat$date + as.Date("1899-12-31")
##
summary(maindat)
## pos country_code country localite category value
## Min. : 2 GN:10258 Guinea :10258 National : 1697 Cases :4083 Min. : 0.0
## 1st Qu.: 5494 LR: 5786 Liberia : 5786 Conakry : 478 Confirmed cases:3612 1st Qu.: 1.0
## Median :10987 ML: 84 Mali : 84 Gueckedou : 478 Deaths :4049 Median : 6.0
## Mean :10987 NG: 364 Nigeria : 364 Kissidougou: 478 New cases :3577 Mean : 113.5
## 3rd Qu.:16480 SL: 5290 Senegal : 189 Macenta : 478 Probable cases :3583 3rd Qu.: 39.0
## Max. :21972 SN: 189 Sierra Leone: 5290 Telimele : 457 Suspected cases:3067 Max. :7009.0
## (Other) :17905 NA's :299
## date sources link sdr_id sdr_name
## Min. :2014-03-25 Gvt :19269 Sitrep 206 07Nov: 312 Min. : 0 : 2211
## 1st Qu.:2014-09-12 gvt : 1338 : 184 1st Qu.: 15 Gueckedou : 493
## Median :2014-10-02 WHO : 917 Sitrep 207 08Nov: 156 Median : 40 Conakry : 487
## Mean :2014-09-30 Ministere de la Sante: 224 Sitrep 208 09Nov: 156 Mean : 7543 Kissidougou: 487
## 3rd Qu.:2014-10-25 GVT : 150 Sitrep 209 10Nov: 156 3rd Qu.: 7848 Macenta : 487
## Max. :2014-11-16 UNICEF : 46 Sitrep 210 11Nov: 156 Max. :157804 Dabola : 486
## (Other) : 27 (Other) :20851 (Other) :17320
## sdr_level
## : 2211
## ADM1: 7690
## ADM2:12048
## ADM3: 2
## PPL : 20
##
##
##
head(maindat)
## pos country_code country localite category value date sources
## 1 2 GN Guinea Guekedou, Macenta, Nzerekore and Kissidougou Cases 86 2014-03-25 WHO
## 2 3 GN Guinea Guekedou, Macenta, Nzerekore and Kissidougou Deaths 59 2014-03-25 WHO
## 3 4 GN Guinea ( Guekedou, Macenta and Kissidougou Cases 86 2014-03-26 WHO
## 4 5 GN Guinea ( Guekedou, Macenta and Kissidougou Deaths 60 2014-03-26 WHO
## 5 6 GN Guinea ( Guekedou, Macenta and Kissidougou Cases 86 2014-03-27 WHO
## 6 7 GN Guinea ( Guekedou, Macenta and Kissidougou) Deaths 62 2014-03-27 WHO
## link sdr_id
## 1 http://reliefweb.int/sites/reliefweb.int/files/resources/guinea_ebola_20140324-2.pdf 8
## 2 http://reliefweb.int/sites/reliefweb.int/files/resources/guinea_ebola_20140324-2.pdf 8
## 3 http://reliefweb.int/sites/reliefweb.int/files/resources/guinea_ebola_20140325.pdf 38
## 4 http://reliefweb.int/sites/reliefweb.int/files/resources/guinea_ebola_20140325.pdf 38
## 5 http://reliefweb.int/report/guinea/fi-vre-h-morragique-virus-ebola-en-guin-e-mise-jour-26-mars-2014 38
## 6 http://reliefweb.int/report/guinea/fi-vre-h-morragique-virus-ebola-en-guin-e-mise-jour-26-mars-2014 38
## sdr_name sdr_level
## 1 Nzerekore ADM1
## 2 Nzerekore ADM1
## 3 Gueckedou ADM2
## 4 Gueckedou ADM2
## 5 Gueckedou ADM2
## 6 Gueckedou ADM2
## Number of records by Countries
maindat %>% extract("country") %>% table
## maindat %>% extract("country")
## Guinea Liberia Mali Nigeria Senegal Sierra Leone
## 10258 5786 84 364 189 5290
## Number of records by Regions and Countries
xtabs( ~ sdr_name + country, maindat)
## country
## sdr_name Guinea Liberia Mali Nigeria Senegal Sierra Leone
## 991 471 22 141 167 419
## Beyla 268 0 0 0 0 0
## Bo 0 0 0 0 0 352
## Boffa 457 0 0 0 0 0
## Boke 226 0 0 0 0 0
## Bombali 0 0 0 0 0 350
## Bomi 0 365 0 0 0 0
## Bong 0 380 0 0 0 0
## Bonthe 0 0 0 0 0 348
## Commune 2 0 0 22 0 0 0
## Commune 5 0 0 18 0 0 0
## Conakry 487 0 0 0 0 0
## Coyah 388 0 0 0 0 0
## Dabola 486 0 0 0 0 0
## Dakar 0 0 0 0 2 0
## Dalaba 328 0 0 0 0 0
## Dinguiraye 484 0 0 0 0 0
## Dubreka 441 0 0 0 0 0
## Faranah 214 0 0 0 0 0
## Freetown 0 0 0 0 0 2
## Gbarpolu 0 334 0 0 0 0
## Grand Bassa 0 365 0 0 0 0
## Grand Cape Mount 0 373 0 0 0 0
## Grand Gedeh 0 367 0 0 0 0
## Grand Kru 0 237 0 0 0 0
## Gueckedou 493 0 0 0 0 0
## Kailahun 0 0 0 0 0 363
## Kambia 0 0 0 0 0 354
## Kankan 204 0 0 0 0 0
## Kayes 0 0 22 0 0 0
## Kenema 0 0 0 0 0 356
## Kerouane 393 0 0 0 0 0
## Kindia 292 0 0 0 0 0
## Kissidougou 487 0 0 0 0 0
## Koinadugu 0 0 0 0 0 352
## Kono 0 0 0 0 0 350
## Kouroussa 451 0 0 0 0 0
## Lagos 0 0 0 130 0 0
## Lofa 0 388 0 0 0 0
## Lola 250 0 0 0 0 0
## Macenta 487 0 0 0 0 0
## Mamou 208 0 0 0 0 0
## Margibi 0 388 0 0 0 0
## Maryland 0 273 0 0 0 0
## Mbaw 0 0 0 0 20 0
## Montserrado 0 384 0 0 0 0
## Moyamba 0 0 0 0 0 352
## Nimba 0 388 0 0 0 0
## Nzerekore 443 0 0 0 0 0
## Pita 441 0 0 0 0 0
## Port Loko 0 0 0 0 0 354
## Pujehun 0 0 0 0 0 348
## River Gee 0 352 0 0 0 0
## Rivercess 0 365 0 0 0 0
## Rivers 0 0 0 93 0 0
## Siguiri 441 0 0 0 0 0
## Sinoe 0 356 0 0 0 0
## Telimele 457 0 0 0 0 0
## Tonkolili 0 0 0 0 0 348
## Western Area 0 0 0 0 0 54
## Western Area Rural 0 0 0 0 0 288
## Western Area Urban 0 0 0 0 0 300
## Yomou 441 0 0 0 0 0
##
cat("### Types of cases by regions\n")
## ### Types of cases by regions
xtabs( ~ sdr_name + category, data = subset(maindat, sdr_level == "ADM2"))
## category
## sdr_name Cases Confirmed cases Deaths New cases Probable cases Suspected cases
## 0 0 0 0 0 0
## Beyla 44 46 44 46 44 44
## Bo 63 58 63 56 61 51
## Boffa 84 75 84 74 76 64
## Boke 0 0 0 0 0 0
## Bombali 62 58 62 56 61 51
## Bomi 0 0 0 0 0 0
## Bong 0 0 0 0 0 0
## Bonthe 61 58 61 56 61 51
## Commune 2 5 5 5 5 1 1
## Commune 5 4 4 4 4 1 1
## Conakry 0 0 0 0 0 0
## Coyah 64 66 64 66 64 64
## Dabola 99 75 98 74 76 64
## Dakar 0 0 0 0 0 0
## Dalaba 54 56 54 56 54 54
## Dinguiraye 98 75 97 74 76 64
## Dubreka 76 75 76 74 76 64
## Faranah 0 0 0 0 0 0
## Freetown 0 0 0 0 0 0
## Gbarpolu 0 0 0 0 0 0
## Grand Bassa 0 0 0 0 0 0
## Grand Cape Mount 0 0 0 0 0 0
## Grand Gedeh 0 0 0 0 0 0
## Grand Kru 0 0 0 0 0 0
## Gueckedou 102 75 101 74 76 65
## Kailahun 67 60 68 56 61 51
## Kambia 64 58 64 56 61 51
## Kankan 0 0 0 0 0 0
## Kayes 0 0 0 0 0 0
## Kenema 65 58 65 56 61 51
## Kerouane 65 67 65 67 65 64
## Kindia 0 0 0 0 0 0
## Kissidougou 99 75 98 74 76 65
## Koinadugu 63 58 63 56 61 51
## Kono 62 58 62 56 61 51
## Kouroussa 81 75 81 74 76 64
## Lagos 0 0 0 0 0 0
## Lofa 0 0 0 0 0 0
## Lola 41 43 41 43 41 41
## Macenta 99 75 98 74 76 65
## Mamou 0 0 0 0 0 0
## Margibi 0 0 0 0 0 0
## Maryland 0 0 0 0 0 0
## Mbaw 0 0 0 0 0 0
## Montserrado 0 0 0 0 0 0
## Moyamba 63 58 63 56 61 51
## Nimba 0 0 0 0 0 0
## Nzerekore 0 0 0 0 0 0
## Pita 76 75 76 74 76 64
## Port Loko 64 58 64 56 61 51
## Pujehun 61 58 61 56 61 51
## River Gee 0 0 0 0 0 0
## Rivercess 0 0 0 0 0 0
## Rivers 0 0 0 0 0 0
## Siguiri 76 75 76 74 76 64
## Sinoe 0 0 0 0 0 0
## Telimele 84 75 84 74 76 64
## Tonkolili 61 58 61 56 61 51
## Western Area 0 0 0 0 0 0
## Western Area Rural 51 48 51 46 51 41
## Western Area Urban 53 50 53 48 53 43
## Yomou 76 75 76 74 76 64
plot1 <- ggplot(data = subset(maindat, sdr_level == "ADM2"),
mapping = aes(x = date, y = value, group = sdr_name, color = sdr_name)) +
layer(geom = "line") +
guides(color = guide_legend(ncol = 2)) +
facet_wrap( ~ category, ncol = 2) +
theme_bw() + theme(legend.key = element_blank())
plot1
geodat <- dataList[[1]]
ggplot(data = geodat, mapping = aes(x = gn_longitude, y = gn_latitude, label = name)) +
layer(geom = "point") +
## layer(geom = "text", size = 3) +
theme_bw() + theme(legend.key = element_blank())
## Extract geocode data for sdr_name existing in maindat
geodatInclded <- geodat[geodat$name %in% maindat$sdr_name, ]
## ggmap
qmplot(x = gn_longitude, y = gn_latitude, data = geodatInclded, source = "google")
## Warning: bounding box given to google - spatial extent only approximate.