library(tidyverse)
library(lubridate)
library(gt)
source("../functions.R")
SDTW, cumulative and scaled long time series
Packages
Dengue data
# tdengue <- readRDS(file = "tdengue.rds")
<- arrow::open_dataset(sources = data_dir("bundled_data/tdengue.parquet")) %>%
dengue select(mun, date, cases, cases_cum) %>%
collect()
Clustering results
<- readRDS(file = "clust_sdtw_ids.rds") cluster_ids
Identify municipalities
<- left_join(dengue, cluster_ids, by = "mun") dengue
Cluster time series plot
ggplot(data = dengue, aes(x = date, y = cases, color = mun)) +
geom_line(alpha = .3) +
facet_wrap(~group) +
theme_bw() +
theme(legend.position = "none")
ggplot(data = dengue, aes(x = date, y = cases_cum, color = mun)) +
geom_line(alpha = .3) +
facet_wrap(~group) +
theme_bw() +
theme(legend.position = "none")
Map clusters
<- geobr::read_municipality(showProgress = FALSE) mun.shp
Loading required namespace: sf
Using year 2010
%>%
mun.shp mutate(code_muni = substr(code_muni, 0, 6)) %>%
left_join(cluster_ids, by = c("code_muni" = "mun")) %>%
ggplot() +
geom_sf(aes(fill = group))