spain2Rep paketeak Espainiako Bigarren Errepublikako Hauteskunde
Atlasaren (1931–1936) hauteskunde- eta testuinguru-datuetarako
sarbide programatikoa eskaintzen du. Paketea sinplea izateko diseinatuta
dago: datuak kargatzeko eta iragazteko funtzio nagusi bat, eta mapak
azkar sortzeko marrazketa- funtzio bat.
Edozein datu kargatu aurretik, paketeak gaur egun zer urte, barruti eta erkidego autonomo hartzen dituen begiratu daiteke:
meta <- rep_metadata()
meta$available_years # hauteskunde-urteak, mailaka
#> $municipality
#> [1] 1936
#>
#> $district
#> [1] 1931 1933 1936
meta$available_referendums # erreferendum-urteak
#> [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() funtzioak bi maila geografiko hartzen ditu
hauteskunde- datuetarako, level argumentuaren bidez
aukeratzeko:
level = "municipality" (lehenetsia) — udalerri
bakoitzeko errenkada bat, 1936 urtea.level = "district" — barruti elektoral bakoitzeko
errenkada bat, 1931, 1933 eta 1936 urteak (1931 eta 1933 barruti mailan
bakarrik daude eskuragarri). detail = "candidates" erabil
daiteke, plataformaka bildutako boto-kuoten ordez hautagai bakoitzeko
errenkada bat lortzeko (kasu horretan geometriarik gabe).rep_data() argumenturik gabe deituta, udalerri mailako
datu-multzo berriena itzultzen da tibble gisa:
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,…Objektuak udalerri bakoitzeko errenkada bat du. Zutabe nagusien artean:
| Zutabea | Deskribapena |
|---|---|
cod_muni |
Udalerriaren INE kodea |
mun |
Udalerriaren izena |
district |
Barruti elektorala |
region |
Erkidego autonomoa |
turnout_real |
Behatutako partaidetza (0–100) |
pct_combined_left_coalition |
Ezkerreko koalizioaren boto-kuota (0–100) |
pct_combined_right_coalition |
Eskuineko koalizioaren boto-kuota (0–100) |
first_platform |
Boto-kuotarik handiena duen koalizioa |
1936ko datuekin, udalerri guztietako partaidetzaren banaketa aztertu dezakegu. Kontuan izan partaidetza falta dela oraindik berreskuratu ez diren hauteskunde-erregistroak dituzten udalerrietan.
ggplot(data_1936, aes(x = turnout_real)) +
geom_histogram(bins = 40, fill = "steelblue", colour = "white", na.rm = TRUE) +
labs(
x = "Partaidetza",
y = "Udalerri kopurua",
title = "Partaidetzaren banaketa udalerrien artean, 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>Barcelona_capital barrutiak lau udalerri zituen. Bi
koalizio nagusien boto-kuotak alboz albo alderatu ditzakegu:
barcelona_long <- bind_rows(
mutate(barcelona, coalition = "Ezkerra", pct = pct_combined_left_coalition),
mutate(barcelona, coalition = "Eskuina", 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(Ezkerra = "#d73027", Eskuina = "#4575b4")) +
scale_y_continuous(labels = function(x) paste0(round(x), "%")) +
coord_flip() +
labs(
x = NULL,
y = "Boto-kuota",
fill = NULL,
title = "Koalizioen boto-kuotak Bartzelona hiriburuko barrutian, 1936"
) +
theme_minimal() +
theme(legend.position = "top")rep_data() funtzioak tibble estandar bat itzultzen du,
beraz modu naturalean uztartzen da dplyr-ekin eta
jatorrizko pipe operadorearekin:
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 100Barruti eta erkidego autonomo bikote bateraezin bat ematen bada, paketeak errore informatibo bat sortzen du:
geometry = TRUE ezarrita, hauteskunde-datuekin dagoeneko
lotutako udalerri-poligonoak dituen sf objektu bat lortzen
da, shapefile bat eskuz kargatu beharrik gabe.
map_data <- rep_data(year = 1936, geometry = TRUE)
class(map_data)
#> [1] "sf" "data.frame"
dim(map_data) # errenkadak = udalerriak, zutabeak = aldagaiak + geometria
#> [1] 8853 130sf objektua zuzenean pasa dakioke
rep_plot()-i, argitaratzeko moduko mapa koropletiko bat
lortzeko. Daturik ez duten udalerriak grisez agertzen dira; datu-eza
area batean pilatzen denean, orban gris horrek shapefile-a moztuta
dagoela iradoki dezake, han balioak besterik gabe falta direla adierazi
beharrean. district_borders = TRUE ezarrita, barruti
elektoralen kontornoak gainjartzen dira (datuen urtearekin bat
datozenak), erreferentzia bisual gisa, area hori maparen parte dela argi
gera dadin. Hemen ezkerreko koalizioaren boto-kuota irudikatzen dugu
udalerri guztietan:
rep_plot(
map_data,
variable = "pct_combined_left_coalition",
title = "Ezkerreko koalizioaren boto-kuota, 1936",
district_borders = TRUE
)first_platform ere irudika dezakegu — udalerri
bakoitzean gehien bozkatutako koalizioa — banaketa geografikoa
begi-kolpe batean ikusteko:
rep_plot(
map_data,
variable = "first_platform",
title = "Udalerriz udalerriko koalizio irabazlea, 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 = "Ezkerreko koalizioa",
right_coalition = "Eskuineko koalizioa",
centrist_platforms = "Zentrista",
basque_nat_coal = "Euskal abertzalea",
other = "Beste batzuk",
`No data` = "Daturik ez"
)
)
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.Iragazte espaziala iragazte tabularrak bezala funtzionatzen du. Hemen
Katalunian kontzentratzen gara eta partaidetza irudikatzen dugu;
district_borders = TRUE-k mapa Katalunian ondo zentratuta
mantentzen du, Espainia osora itzuli beharrean:
rep_data(year = 1936, region = "Cataluña", geometry = TRUE) |>
rep_plot(
variable = "turnout_real",
title = "Partaidetza Katalunian, 1936",
district_borders = TRUE
)rep_plot()-ek ggplot objektu bat itzultzen
duenez, edozein ggplot2 geruzarekin zabaldu daiteke:
rep_plot(
map_data,
variable = "turnout_real",
title = "Partaidetza, 1936",
district_borders = TRUE
) +
theme_void() +
theme(legend.position = "bottom")Udalerri mailako emaitzez gain, paketeak barruti
(circunscripción) elektoral bakoitzaren boto-kuotak biltzen
ditu. 1931ko eta 1933ko datuak eskuragarri dauden maila bakarra da, izan
ere, udalerri mailako emaitzak gaur egun 1936rako baino ez daude
eskuragarri.
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…Barruti mailako boto-kuoten zutabeek udalerri mailako
<estatistikoa>_<plataforma>
izendatze-konbentzio bera jarraitzen dute, baina
pct_combined_<plataforma>-ren ordez
pct_sumbased_<plataforma> erabiltzen dute (barruti
mailan ez dago pct_original/pct_combined
bertsiorik):
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 = "Boto-kuota", fill = "Plataforma",
title = "Barruti mailako boto-kuotak, 1931") +
theme_minimal() +
theme(legend.position = "bottom", axis.text.y = element_text(size = 5))geometry = TRUE ezarrita, barrutien poligonoak lortzen
dira mapa batean irudikatzeko, udalerri mailan bezala:
dist_1931_map <- rep_data(year = 1931, level = "district", geometry = TRUE)
rep_plot(
dist_1931_map,
variable = "pct_sumbased_broad_republican_socialist_coalition",
title = "Koalizio errepublikano-sozialistaren boto-kuota barrutika, 1931"
)Azterketa xeheagorako, detail = "candidates"-ek hautagai
bakoitzeko errenkada bat itzultzen du (geometriarik gabe, mapa
koropletiko batek poligono bakoitzeko balio bakarra behar baitu):
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…Hauteskunde-emaitzez gain, paketeak erreferendum-datuak ere biltzen ditu. Eskuragarri dagoen erreferenduma 1936ko Galiziako Estatutuarena da, A Coruña, Lugo, Ourense eta Pontevedrako 335 udalerri hartzen dituena.
type = "referendum" erabiltzen da hura eskuratzeko:
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,…Zutabe nagusiak hauteskunde-datuenetatik ezberdinak dira:
| Zutabea | Deskribapena |
|---|---|
cod_muni |
Udalerriaren INE kodea |
municipality |
Udalerriaren izena |
province |
Probintzia (A Coruña, Lugo, Ourense, Pontevedra) |
region |
Erkidego autonomoa ("Galicia") |
perc_ayes |
Aldeko ehunekoa |
perc_nay |
Aurkako ehunekoa |
perc_blank |
Boto zurien ehunekoa |
perc_turnout |
Partaidetza-ehunekoa |
Emaitza estatutuaren aldeko babes zabala izan zen. Udalerrien arteko babesaren banaketa aztertu dezakegu:
ggplot(ref, aes(x = perc_ayes)) +
geom_histogram(bins = 30, fill = "#27ae60", colour = "white", na.rm = TRUE) +
labs(
x = "Aldeko boto-ehunekoa",
y = "Udalerri kopurua",
title = "Galiziako Estatutuaren aldeko babesa udalerriz udalerri, 1936"
) +
theme_minimal()Erreferendum-datuek ere geometry = TRUE onartzen dute.
335 udalerrietatik 21ek ez dute geometriarik (1936 baino lehen
auzo-udalerri batek irentsita, 1936 ondoren sortuak, edo 1930eko
shapefile-ko poligono batekin bat etortzerik ez dutenak direlako), beraz
mapatik kanpo geratzen dira baina datu tabularretan mantentzen dira:
ref_map <- rep_data(year = 1936, type = "referendum", geometry = TRUE)
rep_plot(
ref_map,
variable = "perc_ayes",
title = "Galiziako Estatutuaren aldeko babesa, 1936",
district_borders = TRUE
)Pakete hau zure ikerketan erabiltzen baduzu, mesedez aipatu bai paketea bai Espainiako Bigarren Errepublikako Hauteskunde Atlasa:
Hauteskunde Atlasaren proiektua hemen dago dokumentatuta: https://www.tonirodon.cat/second-republic-atlas/en/.