The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

GERDA: German Election Data for R

This R package provides data on German elections since 1945, together with helpers for merging socioeconomic covariates. Its downloadable catalog contains 47 datasets covering:

The package also bundles INKAR county covariates (1995–2022), Zensus 2022 municipality data, and a ParlGov party crosswalk.

GERDA was compiled by Vincent Heddesheimer, Florian Sichart, Andreas Wiedemann, and Hanno Hilbig. See the GERDA website and the accompanying publication: doi.org/10.1038/s41597-025-04811-5. The package is under active development; comments and bug reports are welcome at hhilbig@ucdavis.edu or via GitHub issues.

Installation

install.packages("gerda")                  # from CRAN
devtools::install_github("hhilbig/gerda")  # development version

To install the vignette along with the development version, pass build_vignettes = TRUE:

devtools::install_github("hhilbig/gerda", build_vignettes = TRUE)

Then read the general introduction with vignette("gerda"). For a fail-closed research workflow designed for coding agents, use vignette("agent-workflow"). CRAN releases ship both vignettes by default.

Main functions

Data access:

Bundled data (no download required):

Merging helpers:

Party mapping:

Choosing an election dataset

Dataset choice affects the research design:

Use the structured catalog to narrow the choice before downloading:

catalog <- gerda_data_list(print_table = FALSE)
subset(catalog,
       election_type == "federal" &
       geographic_level == "municipality" &
       boundary == "2025")

Example

library(gerda)
library(dplyr)

federal <- load_gerda_web(
  "federal_muni_harm_25",
  on_error = "stop",
  cache = TRUE
) |>
  add_gerda_covariates(unmatched = "error") |>
  add_gerda_census(unmatched = "error")

join_report <- gerda_join_diagnostics(federal)

stopifnot(
  is.data.frame(federal),
  nrow(federal) > 0,
  all(c("ags", "election_year") %in% names(federal)),
  all(join_report$input_rows == join_report$output_rows),
  all(join_report$unexpected_unmatched_rows == 0L)
)

The join helpers require five-digit county codes and eight-digit municipality AGS codes to be character vectors, so lost leading zeros cannot pass silently. They also reject duplicate reference keys, output-column conflicts, and row expansion. INKAR years outside 1995–2022 are reported separately from unexpected unmatched keys. Use unmatched = "error" in unattended scripts and inspect gerda_join_diagnostics() immediately after joining.

County covariates (INKAR, 1995–2022)

add_gerda_covariates() appends 30 county-level indicators to federal, state, or local election data. Variables cover demographics, GDP and sectoral structure, unemployment (overall, youth, long-term), education, income, healthcare, childcare, housing, transport, and municipal public finances. Coverage is strongest for 1998–2021; newer indicators are available only for recent years. Use gerda_covariates_codebook() for per-variable detail including original INKAR codes and missing-data rates.

Zensus 2022 (municipality-level)

add_gerda_census() appends 14 indicators from the German Zensus 2022. Because the census is a single 2022 snapshot, the same values are attached to all election years; analyses that rely on within-unit variation in these variables are not supported.

Indicators cover population and age structure (under 18, 18–29, 30–49, 50–59, and 60+), migration background, household size, and housing (dwellings, vacancy, ownership, rent per square metre, single-family share). The Destatis source groups ages 60–74 together, so it cannot support separate 50–64 and 65+ measures. Most variables have above 95% municipality coverage. avg_household_size_census22 is missing for about 12.5% of municipalities because Destatis suppresses small-cell values.

Deprecations

As of v0.8, the upstream federal_cty_unharm columns ags and year are renamed to the canonical GERDA county-level names county_code and election_year on load (the deprecated ags/year duplicates announced in v0.6 have been removed). Use county_code and election_year, which match the rest of the county-level datasets and work directly with add_gerda_covariates().

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.