-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00-exploratory-analysis.qmd
59 lines (49 loc) · 1.17 KB
/
00-exploratory-analysis.qmd
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
---
title: "Exploratory data analysis"
author: "Diego Villa"
format: html
editor: source
---
```{r}
#| warning: false
#| message: false
library(dplyr)
library(ggplot2)
```
## Spatio-temporal maps
```{r}
file_path = "data/processed/dengue-climate.csv"
dengue_climate = readr::read_csv(file_path)
glimpse(dengue_climate)
```
```{r}
dengue = dengue_climate |>
# mutate(incidence = 100000 * (cases / population)) |>
group_by(ubigeo, year) |>
# summarise(incidence = sum(incidence, na.rm = TRUE), .groups = "drop")
summarise(cases = sum(cases, na.rm = TRUE), .groups = "drop")
```
```{r}
library(sf)
dengue_climate_geom = readRDS("data/processed/dengue-climate-geom.rds")
```
```{r}
dengue_geom = dengue |>
left_join(dengue_climate_geom, by = "ubigeo") |>
st_as_sf()
```
```{r}
#| fig-width: 8
#| fig-height: 9
dengue_years_plot = ggplot(dengue_geom) +
facet_wrap(~year, ncol = 3) +
geom_sf(aes(fill = log(cases + 1)), color = NA) +
theme_void() +
theme(legend.position = "bottom") +
scale_fill_viridis_c(name = "Cumulative\ncases")
dengue_years_plot
```
```{r}
#| eval: false
ggsave("figures/dengue-cases-years.png", dengue_years_plot, width = 8, height = 9)
```