spain2Rep provides programmatic access to electoral and
contextual data from the Electoral
Atlas of the Spanish Second Republic (1931–1936). The package is
designed to be simple: one main function to load and filter data, and
one plotting function for quick maps.
Before loading any data, inspect what years, districts, and regions the package currently covers:
meta <- rep_metadata()
meta$available_years # election years, by level
#> $municipality
#> [1] 1936
#>
#> $district
#> [1] 1931 1933 1936
meta$available_referendums # referendum years
#> [1] 1936
meta$regions
#> [1] "Andalucía" "Aragón"
#> [3] "Asturias (Principado de )" "Balears (Illes)"
#> [5] "Canarias" "Cantabria"
#> [7] "Castilla y León" "Castilla-La Mancha"
#> [9] "Cataluña" "Ceuta"
#> [11] "Comunitat Valenciana" "Extremadura"
#> [13] "Galicia" "Madrid (Comunidad de )"
#> [15] "Melilla" "Murcia (Región de )"
#> [17] "Navarra (Comunidad Foral de )" "País Vasco"
#> [19] "Rioja (La)"rep_data() covers two geographic levels for election
data, set with the level argument:
level = "municipality" (default) — one row per
municipality, year 1936.level = "district" — one row per electoral district,
years 1931, 1933, and 1936 (1931 and 1933 are only available at the
district level). Pass detail = "candidates" to get one row
per individual candidate instead of platform-grouped shares (no geometry
support in that case).rep_data() with no arguments returns the most recent
municipality-level dataset as a tibble:
data <- rep_data()
glimpse(data)
#> Rows: 8,853
#> Columns: 129
#> $ cod_muni <chr> "03002", "03003…
#> $ region <chr> "Comunitat Vale…
#> $ cod_ccaa <chr> "10", "10", "10…
#> $ prov <chr> "Alicante/Alaca…
#> $ cod_prov <chr> "03", "03", "03…
#> $ prov_cap <dbl> 0, 0, 0, 0, 0, …
#> $ island <chr> NA, NA, NA, NA,…
#> $ PJ <chr> "Novelda", "Coc…
#> $ PJ_cap <dbl> 0, 0, 0, 0, 0, …
#> $ elect_round <dbl> 1, 1, 1, 1, 1, …
#> $ year <dbl> 1936, 1936, 193…
#> $ date <chr> "1936/02/16 00:…
#> $ district <chr> "Alicante", "Al…
#> $ total_seats <dbl> 11, 11, 11, 11,…
#> $ majority_seats <dbl> 8, 8, 8, 8, 8, …
#> $ mun <chr> "Agost", "Agres…
#> $ elect <dbl> NA, NA, NA, NA,…
#> $ votant <dbl> NA, NA, NA, NA,…
#> $ elect_est <dbl> 1555, 681, 582,…
#> $ turnout_real <dbl> NA, NA, NA, NA,…
#> $ turnout_est <dbl> 71.19, 76.67, 8…
#> $ total_votes <dbl> 8856, 4177, 380…
#> $ total_sections <dbl> 4, 2, 2, 2, 1, …
#> $ missing_sections <dbl> 0, 0, 0, 0, 0, …
#> $ completeness_pct <dbl> 100, 100, 100, …
#> $ data_source <chr> "ACD", "ACD", "…
#> $ first_platform <chr> "left_coalition…
#> $ sum_votes_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_other <dbl> 52, 26, 9, 0, 0…
#> $ sum_votes_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ sum_votes_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ sum_votes_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_otros <dbl> NA, NA, NA, NA,…
#> $ sum_votes_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ sum_votes_left_coalition <dbl> 5395, 2144, 263…
#> $ sum_votes_right_coalition <dbl> 3409, 2007, 116…
#> $ sum_votes_centrist_platforms <dbl> 0, 0, 1, 19, 0,…
#> $ sum_votes_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ sum_votes_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ mean_votes_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_other <dbl> 17.33, 8.67, 3.…
#> $ mean_votes_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ mean_votes_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ mean_votes_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_otros <dbl> NA, NA, NA, NA,…
#> $ mean_votes_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ mean_votes_left_coalition <dbl> 674.38, 268.00,…
#> $ mean_votes_right_coalition <dbl> 426.12, 250.88,…
#> $ mean_votes_centrist_platforms <dbl> 0, 0, 1, 19, 0,…
#> $ mean_votes_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ mean_votes_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_original_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_other <dbl> NA, NA, NA, NA,…
#> $ pct_original_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ pct_original_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_original_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_otros <dbl> NA, NA, NA, NA,…
#> $ pct_original_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ pct_original_left_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_original_right_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_original_centrist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_original_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_other <dbl> 0.59, 0.62, 0.2…
#> $ pct_sumbased_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_otros <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_left_coalition <dbl> 60.92, 51.33, 6…
#> $ pct_sumbased_right_coalition <dbl> 38.49, 48.05, 3…
#> $ pct_sumbased_centrist_platforms <dbl> 0.00, 0.00, 0.0…
#> $ pct_sumbased_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_sumbased_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_other <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_otros <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_left_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_right_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_centrist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_meanbased_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_combined_center_right_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_communist_and_other_lw_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_left_wing_republican_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_other <dbl> 0.59, 0.62, 0.2…
#> $ pct_combined_right_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_right_wing_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_socialist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_blank_and_null <dbl> NA, NA, NA, NA,…
#> $ pct_combined_left_wing_republican_socialist_coalition <dbl> NA, NA, NA, NA,…
#> $ pct_combined_left_wing_regionalist_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_otros <dbl> NA, NA, NA, NA,…
#> $ pct_combined_basque_nat_coal <dbl> NA, NA, NA, NA,…
#> $ pct_combined_left_coalition <dbl> 60.92, 51.33, 6…
#> $ pct_combined_right_coalition <dbl> 38.49, 48.05, 3…
#> $ pct_combined_centrist_platforms <dbl> 0.00, 0.00, 0.0…
#> $ pct_combined_socialist_led_platforms <dbl> NA, NA, NA, NA,…
#> $ pct_combined_republican_socialist_coalition <dbl> NA, NA, NA, NA,…The object has one row per municipality. Key columns include:
| Column | Description |
|---|---|
cod_muni |
INE municipality code |
mun |
Municipality name |
district |
Electoral circumscription |
region |
Autonomous community |
turnout_real |
Observed turnout (0–100) |
pct_combined_left_coalition |
Left-coalition vote share (0–100) |
pct_combined_right_coalition |
Right-coalition vote share (0–100) |
first_platform |
Coalition with the highest vote share |
With the 1936 data in hand, we can look at the distribution of turnout across all municipalities. Note that turnout is missing for municipalities where electoral records have not yet been recovered.
ggplot(data_1936, aes(x = turnout_real)) +
geom_histogram(bins = 40, fill = "steelblue", colour = "white", na.rm = TRUE) +
labs(
x = "Turnout",
y = "Number of municipalities",
title = "Turnout distribution across municipalities, 1936"
) +
theme_minimal()barcelona <- rep_data(district = "Barcelona_capital")
select(barcelona, mun, turnout_real,
pct_combined_left_coalition, pct_combined_right_coalition,
first_platform)
#> # A tibble: 4 × 5
#> mun turnout_real pct_combined_left_co…¹ pct_combined_right_c…²
#> <chr> <dbl> <dbl> <dbl>
#> 1 Sant Adrià de Besòs NA 74.3 25.6
#> 2 Santa Coloma de Gr… NA 75.6 24.3
#> 3 Badalona NA 66.2 33.8
#> 4 Barcelona 67.8 62.6 37.3
#> # ℹ abbreviated names: ¹pct_combined_left_coalition,
#> # ²pct_combined_right_coalition
#> # ℹ 1 more variable: first_platform <chr>The Barcelona_capital district comprised four
municipalities. We can compare the vote shares of the two main
coalitions side by side:
barcelona_long <- bind_rows(
mutate(barcelona, coalition = "Left", pct = pct_combined_left_coalition),
mutate(barcelona, coalition = "Right", pct = pct_combined_right_coalition)
)
ggplot(barcelona_long, aes(x = reorder(mun, pct), y = pct, fill = coalition)) +
geom_col(position = "dodge") +
scale_fill_manual(values = c(Left = "#d73027", Right = "#4575b4")) +
scale_y_continuous(labels = function(x) paste0(round(x), "%")) +
coord_flip() +
labs(
x = NULL,
y = "Vote share",
fill = NULL,
title = "Coalition vote shares in the Barcelona capital district, 1936"
) +
theme_minimal() +
theme(legend.position = "top")rep_data() returns a standard tibble, so it integrates
naturally with dplyr and the native pipe:
rep_data(year = 1936) |>
filter(turnout_real > 75) |>
select(mun, district, region, turnout_real) |>
arrange(desc(turnout_real)) |>
head(10)
#> # A tibble: 10 × 4
#> mun district region turnout_real
#> <chr> <chr> <chr> <dbl>
#> 1 Valdeavero Madrid_provincia Madrid (Comunidad de ) 100
#> 2 Santa Eulalia Bajera Logroño Rioja (La) 100
#> 3 Canejan Lleida Cataluña 100
#> 4 Sarroca de Segre Lleida Cataluña 100
#> 5 Alcanó Lleida Cataluña 100
#> 6 Sant Pere dels Arquells Lleida Cataluña 100
#> 7 Abella de la Conca Lleida Cataluña 100
#> 8 Villanueva la Condesa Valladolid Castilla y León 100
#> 9 Pías Zamora Castilla y León 100
#> 10 Otero de Centenos Zamora Castilla y León 100If you supply an inconsistent district–region pair, the package raises an informative error:
Set geometry = TRUE to receive an sf object
with municipal polygons already joined to the electoral data — no manual
shapefile loading required.
map_data <- rep_data(year = 1936, geometry = TRUE)
class(map_data)
#> [1] "sf" "data.frame"
dim(map_data) # rows = municipalities, cols = variables + geometry
#> [1] 8853 130Pass the sf object directly to rep_plot()
for a publication-ready choropleth. Municipalities with missing data are
shown in grey; when missing data clusters in one area, the grey patch
can look like the shapefile was clipped rather than simply lacking
values there. Set district_borders = TRUE to overlay
electoral-district outlines (matched to the year of the data) as a
visual reference, so it stays clear that the area is part of the map.
Here we map left-coalition vote share across all municipalities:
rep_plot(
map_data,
variable = "pct_combined_left_coalition",
title = "Left-coalition vote share, 1936",
district_borders = TRUE
)We can also map first_platform — the coalition that came
first in each municipality — to see the geographic divide at a
glance:
rep_plot(
map_data,
variable = "first_platform",
title = "Winning coalition by municipality, 1936",
district_borders = TRUE
) +
scale_fill_manual(
values = c(
left_coalition = "#c0392b",
right_coalition = "#2980b9",
centrist_platforms = "#e67e22",
basque_nat_coal = "#27ae60",
other = "#8e44ad",
`No data` = "grey85"
),
labels = c(
left_coalition = "Left coalition",
right_coalition = "Right coalition",
centrist_platforms = "Centrist",
basque_nat_coal = "Basque nationalist",
other = "Other",
`No data` = "No data"
)
)
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.Spatial filtering works exactly like tabular filtering. Here we zoom
in on Cataluña and map turnout; district_borders = TRUE
keeps the map correctly zoomed to Cataluña rather than snapping back out
to all of Spain:
rep_data(year = 1936, region = "Cataluña", geometry = TRUE) |>
rep_plot(
variable = "turnout_real",
title = "Turnout in Cataluña, 1936",
district_borders = TRUE
)Because rep_plot() returns a ggplot object,
you can extend it with any ggplot2 layer:
rep_plot(
map_data,
variable = "turnout_real",
title = "Turnout, 1936",
district_borders = TRUE
) +
theme_void() +
theme(legend.position = "bottom")Alongside municipality-level results, the package bundles vote shares
for each electoral district
(circunscripción). This is the only level at which 1931 and
1933 data are available, since municipality-level results are currently
bundled for 1936 only.
dist_1931 <- rep_data(year = 1931, level = "district")
glimpse(dist_1931)
#> Rows: 63
#> Columns: 90
#> $ region <chr> "Comunitat…
#> $ cod_ccaa <dbl> 10, 8, 1, …
#> $ prov <chr> "Alicante/…
#> $ cod_prov <chr> "03", "02"…
#> $ year <dbl> 1931, 1931…
#> $ date <date> 1931-06-2…
#> $ election_round <dbl> 1, 1, 1, 1…
#> $ district <chr> "Alicante"…
#> $ total_seats <dbl> 11, 7, 7, …
#> $ majority_seats <dbl> 8, 5, 5, 1…
#> $ elect <dbl> 159932, 86…
#> $ votant <dbl> 111186, 62…
#> $ turnout <dbl> 69.52, 71.…
#> $ total_votes <dbl> 839236, 28…
#> $ data_source <chr> "Credentia…
#> $ sum_votes_left_wing_republican_socialist_coalition <dbl> 507108, NA…
#> $ sum_votes_right_wing_platforms <dbl> NA, 19143,…
#> $ sum_votes_right_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ sum_votes_broad_republican_socialist_coalition <dbl> NA, 216962…
#> $ sum_votes_center_right_republican_platforms <dbl> 237769, 28…
#> $ sum_votes_left_wing_republican_platforms <dbl> 46254, 232…
#> $ sum_votes_other <dbl> 48105, 387…
#> $ sum_votes_socialist_platforms <dbl> NA, NA, 61…
#> $ sum_votes_communist_and_other_lw_platforms <dbl> NA, NA, NA…
#> $ sum_votes_left_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ sum_votes_otros <dbl> NA, NA, NA…
#> $ sum_votes_basque_nat_coal <dbl> NA, NA, NA…
#> $ sum_votes_left_coalition <dbl> NA, NA, NA…
#> $ sum_votes_right_coalition <dbl> NA, NA, NA…
#> $ sum_votes_centrist_platforms <dbl> NA, NA, NA…
#> $ mean_votes_left_wing_republican_socialist_coalition <dbl> 63388.50, …
#> $ mean_votes_right_wing_platforms <dbl> NA, 6381.0…
#> $ mean_votes_right_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ mean_votes_broad_republican_socialist_coalition <dbl> NA, 43392.…
#> $ mean_votes_center_right_republican_platforms <dbl> 29721.12, …
#> $ mean_votes_left_wing_republican_platforms <dbl> 11563.50, …
#> $ mean_votes_other <dbl> 8017.50, 3…
#> $ mean_votes_socialist_platforms <dbl> NA, NA, 12…
#> $ mean_votes_communist_and_other_lw_platforms <dbl> NA, NA, NA…
#> $ mean_votes_left_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ mean_votes_otros <dbl> NA, NA, NA…
#> $ mean_votes_basque_nat_coal <dbl> NA, NA, NA…
#> $ mean_votes_left_coalition <dbl> NA, NA, NA…
#> $ mean_votes_right_coalition <dbl> NA, NA, NA…
#> $ mean_votes_centrist_platforms <dbl> NA, NA, NA…
#> $ pct_sumbased_left_wing_republican_socialist_coalition <dbl> 60.42, NA,…
#> $ pct_sumbased_right_wing_platforms <dbl> NA, 6.65, …
#> $ pct_sumbased_right_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ pct_sumbased_broad_republican_socialist_coalition <dbl> NA, 75.33,…
#> $ pct_sumbased_center_right_republican_platforms <dbl> 28.33, 9.8…
#> $ pct_sumbased_left_wing_republican_platforms <dbl> 5.51, 8.06…
#> $ pct_sumbased_other <dbl> 5.73, 0.13…
#> $ pct_sumbased_socialist_platforms <dbl> NA, NA, 23…
#> $ pct_sumbased_communist_and_other_lw_platforms <dbl> NA, NA, NA…
#> $ pct_sumbased_left_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ pct_sumbased_otros <dbl> NA, NA, NA…
#> $ pct_sumbased_basque_nat_coal <dbl> NA, NA, NA…
#> $ pct_sumbased_left_coalition <dbl> NA, NA, NA…
#> $ pct_sumbased_right_coalition <dbl> NA, NA, NA…
#> $ pct_sumbased_centrist_platforms <dbl> NA, NA, NA…
#> $ pct_meanbased_left_wing_republican_socialist_coalition <dbl> 57.01, NA,…
#> $ pct_meanbased_right_wing_platforms <dbl> NA, 10.28,…
#> $ pct_meanbased_right_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ pct_meanbased_broad_republican_socialist_coalition <dbl> NA, 69.89,…
#> $ pct_meanbased_center_right_republican_platforms <dbl> 26.73, 9.1…
#> $ pct_meanbased_left_wing_republican_platforms <dbl> 10.40, 18.…
#> $ pct_meanbased_other <dbl> 7.21, 0.62…
#> $ pct_meanbased_socialist_platforms <dbl> NA, NA, 21…
#> $ pct_meanbased_communist_and_other_lw_platforms <dbl> NA, NA, NA…
#> $ pct_meanbased_left_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ pct_meanbased_otros <dbl> NA, NA, NA…
#> $ pct_meanbased_basque_nat_coal <dbl> NA, NA, NA…
#> $ pct_meanbased_left_coalition <dbl> NA, NA, NA…
#> $ pct_meanbased_right_coalition <dbl> NA, NA, NA…
#> $ pct_meanbased_centrist_platforms <dbl> NA, NA, NA…
#> $ elected_candidates_left_wing_republican_socialist_coalition <dbl> 8, NA, NA,…
#> $ elected_candidates_right_wing_platforms <dbl> NA, 0, 0, …
#> $ elected_candidates_right_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ elected_candidates_broad_republican_socialist_coalition <dbl> NA, 5, NA,…
#> $ elected_candidates_center_right_republican_platforms <dbl> 3, 0, 1, N…
#> $ elected_candidates_left_wing_republican_platforms <dbl> 0, 1, 4, N…
#> $ elected_candidates_other <dbl> 0, 0, 0, N…
#> $ elected_candidates_socialist_platforms <dbl> NA, NA, 2,…
#> $ elected_candidates_communist_and_other_lw_platforms <dbl> NA, NA, NA…
#> $ elected_candidates_left_wing_regionalist_platforms <dbl> NA, NA, NA…
#> $ elected_candidates_otros <dbl> NA, NA, NA…
#> $ elected_candidates_basque_nat_coal <dbl> NA, NA, NA…
#> $ elected_candidates_left_coalition <dbl> NA, NA, NA…
#> $ elected_candidates_right_coalition <dbl> NA, NA, NA…
#> $ elected_candidates_centrist_platforms <dbl> NA, NA, NA…District-level share columns follow the same
<statistic>_<platform> naming convention as the
municipality level, but use pct_sumbased_<platform>
rather than pct_combined_<platform> (there is no
pct_original/pct_combined variant at the
district level):
dist_1931 |>
select(district, starts_with("pct_sumbased_")) |>
pivot_longer(starts_with("pct_sumbased_"), names_prefix = "pct_sumbased_",
names_to = "platform", values_to = "pct") |>
filter(!is.na(pct), pct > 0) |>
ggplot(aes(x = reorder(district, pct, FUN = max), y = pct, fill = platform)) +
geom_col() +
coord_flip() +
labs(x = NULL, y = "Vote share", fill = "Platform",
title = "District-level vote shares, 1931") +
theme_minimal() +
theme(legend.position = "bottom", axis.text.y = element_text(size = 5))Set geometry = TRUE to get district polygons for
mapping, just like at the municipality level:
dist_1931_map <- rep_data(year = 1931, level = "district", geometry = TRUE)
rep_plot(
dist_1931_map,
variable = "pct_sumbased_broad_republican_socialist_coalition",
title = "Republican-Socialist coalition vote share by district, 1931"
)For finer-grained analysis, detail = "candidates"
returns one row per individual candidate (no geometry, since a
choropleth needs one value per polygon):
candidates_1936 <- rep_data(year = 1936, level = "district", detail = "candidates")
candidates_1936 |>
filter(district == "Barcelona_provincia") |>
select(full_cand_name, party_short, platform_summ, votes, elected_status) |>
arrange(desc(votes)) |>
head(10)
#> # A tibble: 10 × 5
#> full_cand_name party_short platform_summ votes elected_status
#> <chr> <chr> <chr> <dbl> <chr>
#> 1 Juan Lluhí Vallescá PNRE left_coalition 196613 elected_first_rou…
#> 2 Eduardo Ragasol Serrá ACR left_coalition 196326 elected_first_rou…
#> 3 José Tomás Piera ERC left_coalition 196057 elected_first_rou…
#> 4 Pedro Mestres Albet ERC left_coalition 196028 elected_first_rou…
#> 5 Francisco Senyal Ferrer ERC left_coalition 195906 elected_first_rou…
#> 6 Domingo Palet Barba ERC left_coalition 195880 elected_first_rou…
#> 7 José Antonio Trabal Sans ERC left_coalition 195680 elected_first_rou…
#> 8 Pablo Padró Canyellas II left_coalition 195423 elected_first_rou…
#> 9 José Calvet Mora II left_coalition 195319 elected_first_rou…
#> 10 Jaime Comas Jo USC left_coalition 194986 elected_first_rou…In addition to election results, the package includes referendum data. The available referendum is the 1936 Galicia Statute (Estatuto de Autonomía de Galicia), covering 335 municipalities across A Coruña, Lugo, Ourense, and Pontevedra.
Use type = "referendum" to access it:
ref <- rep_data(year = 1936, type = "referendum")
glimpse(ref)
#> Rows: 335
#> Columns: 9
#> $ cod_muni <chr> "15001", "15002", "15003", "15004", "15005", "15006", "15…
#> $ municipality <chr> "Abegondo", "Ames", "Aranga", "Ares", "Arteijo", "Arzua",…
#> $ province <chr> "A Coruña", "A Coruña", "A Coruña", "A Coruña", "A Coruña…
#> $ region <chr> "Galicia", "Galicia", "Galicia", "Galicia", "Galicia", "G…
#> $ year <int> 1936, 1936, 1936, 1936, 1936, 1936, 1936, 1936, 1936, 193…
#> $ perc_ayes <dbl> NA, 100.00, 99.05, 99.92, 98.90, NA, NA, 99.66, 100.00, N…
#> $ perc_nay <dbl> NA, 0.00, 0.95, 0.08, 1.10, NA, NA, 0.17, 0.00, NA, NA, 0…
#> $ perc_blank <dbl> NA, 0.00, 0.00, 0.00, 0.00, NA, NA, 0.17, 0.00, NA, NA, 0…
#> $ perc_turnout <dbl> NA, 93.41, 89.00, 92.71, 88.26, NA, NA, 43.27, 70.65, NA,…Key columns differ from election data:
| Column | Description |
|---|---|
cod_muni |
INE municipality code |
municipality |
Municipality name |
province |
Province (A Coruña, Lugo, Ourense, Pontevedra) |
region |
Autonomous community ("Galicia") |
perc_ayes |
Percentage in favour |
perc_nay |
Percentage against |
perc_blank |
Percentage blank |
perc_turnout |
Turnout percentage |
The result was an overwhelming endorsement of the statute. We can look at the distribution of support across municipalities:
ggplot(ref, aes(x = perc_ayes)) +
geom_histogram(bins = 30, fill = "#27ae60", colour = "white", na.rm = TRUE) +
labs(
x = "% votes in favour",
y = "Number of municipalities",
title = "Support for the Galicia Statute by municipality, 1936"
) +
theme_minimal()Referendum data also supports geometry = TRUE. 21 of the
335 municipalities have no bundled geometry (annexed by a neighbour
before 1936, created after 1936, or otherwise not resolvable to a
1930-shapefile polygon), so they are dropped from the map but remain in
the tabular data:
ref_map <- rep_data(year = 1936, type = "referendum", geometry = TRUE)
rep_plot(
ref_map,
variable = "perc_ayes",
title = "Support for the Galicia Statute, 1936",
district_borders = TRUE
)If you use this package in your research, please cite both the package and the Electoral Atlas of the Spanish Second Republic:
The Electoral Atlas project is documented at https://www.tonirodon.cat/second-republic-atlas/en/.