knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
xfun::pkg_attach(c("tidyverse", "magrittr", "xml2", "sf", "scales", "ggiraph"))
Warning: package 'ggplot2' was built under R version 4.4.3
Warning: package 'tibble' was built under R version 4.4.3
Warning: package 'purrr' was built under R version 4.4.3
Warning: package 'dplyr' was built under R version 4.4.3
Warning: package 'lubridate' was built under R version 4.4.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.0     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   4.0.3     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.0.4     
── 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

Attaching package: 'magrittr'


The following object is masked from 'package:purrr':

    set_names


The following object is masked from 'package:tidyr':

    extract
Warning: package 'xml2' was built under R version 4.4.3
Warning: package 'sf' was built under R version 4.4.3
Linking to GEOS 3.13.0, GDAL 3.10.1, PROJ 9.5.1; sf_use_s2() is TRUE
Warning: package 'scales' was built under R version 4.4.3

Attaching package: 'scales'

The following object is masked from 'package:purrr':

    discard

The following object is masked from 'package:readr':

    col_factor
Warning: package 'ggiraph' was built under R version 4.4.3
gh <- "https://raw.githubusercontent.com/jfronc/volbycz/main/"
source(paste0(gh, "utils/bubble_map.R"))
source(paste0(gh, "senate/create_senate_map.R"))

cache <- readRDS(here::here("senat/2020/data.rds"))

district_data <- cache$election %>% filter(so_id == params$so_id)

maps <- create_senate_map(
  target_so_id = params$so_id,
  district_data      = district_data,
  municipality_cache = cache$municipalities,
  quarter_cache      = cache$quarters
)
Warning: st_centroid assumes attributes are constant over geometries
Warning: st_centroid assumes attributes are constant over geometries