-
Notifications
You must be signed in to change notification settings - Fork 0
/
notebook.Rmd
119 lines (101 loc) · 3.54 KB
/
notebook.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
title: "Untitled"
output: html_document
date: "2024-04-08"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
```
```{r cars}
data_long <- read.csv("data/raw/ebola_2014_2016_clean.csv") |>
mutate(
Cases = Cumulative.no..of.confirmed..probable.and.suspected.cases,
Deaths = Cumulative.no..of.confirmed..probable.and.suspected.deaths,
Date = as.Date(Date)
) |>
select(-Cumulative.no..of.confirmed..probable.and.suspected.cases,
-Cumulative.no..of.confirmed..probable.and.suspected.deaths,) |>
mutate(Cases = if_else(Country == 'Liberia' & Date > "2015-06-19",
10666,
Cases)) |>
mutate(Deaths = if_else(Country == 'Liberia' & Date > "2015-06-19",
4806,
Deaths)) |>
pivot_longer(cols = c(Cases, Deaths),
names_to = 'Statistic',
values_to = 'Value')
data_long
```
```{r}
write.csv(data_long, file = "data/clean/ebola_long.csv", row.names = FALSE)
```
```{r}
data_short <- read.csv("data/raw/ebola_2014_2016_clean.csv") |>
mutate(
Cases = Cumulative.no..of.confirmed..probable.and.suspected.cases,
Deaths = Cumulative.no..of.confirmed..probable.and.suspected.deaths,
Date = as.Date(Date)
) |>
select(-Cumulative.no..of.confirmed..probable.and.suspected.cases,
-Cumulative.no..of.confirmed..probable.and.suspected.deaths,)|>
mutate(Cases = if_else(Country == 'Liberia' & Date > "2015-06-19",
10666,
Cases)) |>
mutate(Deaths = if_else(Country == 'Liberia' & Date > "2015-06-19",
4806,
Deaths))
data_short
```
```{r}
write.csv(data_short, file = "data/clean/ebola_short.csv", row.names = FALSE)
```
```{r}
colnames(data_short)
```
```{r}
ggplot(filter(data_short, Country == 'Guinea'),
aes(x = Date, y = Value, color = Statistic, group = Statistic)) +
geom_line(aes(color = factor(Statistic))) +
scale_color_manual(values = c("Cases" = "red", "Deaths" = "purple")) +
labs(
x = "Date",
y = "Number of Cases or Deaths",
title = "Cumulative Number of Confirmed, Probable, and Suspected Cases and Deaths"
)
```
"cerulean" "cosmo" "cyborg" "darkly" "flatly"
"journal" "litera" "lumen" "lux" "materia"
"minty" "morph" "pulse" "quartz" "sandstone"
"simplex" "sketchy" "slate" "solar" "spacelab"
"superhero" "united" "vapor" "yeti" "zephyr"
```{r}
plot_ly(data, type='choropleth', locationmode = 'country names',
locations=~Country, z=~Cases, text=~Country, color=~Cases,
colorscale='Portland') %>%
layout(title = "Worldwide Cases")
```
```{r}
data <- read.csv("data/raw/ebola_2014_2016_clean.csv") |>
mutate(
Cases = Cumulative.no..of.confirmed..probable.and.suspected.cases,
Deaths = Cumulative.no..of.confirmed..probable.and.suspected.deaths,
Date = as.Date(Date)
) |>
select(-Cumulative.no..of.confirmed..probable.and.suspected.cases,
-Cumulative.no..of.confirmed..probable.and.suspected.deaths,) |>
mutate(Cases = if_else(Country == 'Liberia' & Date > "2015-06-19",
10666,
Cases)) |>
mutate(Deaths = if_else(Country == 'Liberia' & Date > "2015-06-19",
4806,
Deaths))
data
```
```{r}
ggplot(filter(data, Country =='Liberia'),
aes(x = Date, y = Deaths)) +
geom_line()
```