R Package

The gerda R package provides tools to download and work with GERDA datasets directly in R. Current version: 0.8.1, available on CRAN since 27 July 2026 and matching the development version on GitHub. As of v0.8 the package exposes 47 datasets covering local, state, federal, mayoral, Landrat (county executive), European Parliament, and county (Kreistag) elections, including federal and state results at the constituency (Wahlkreis) level, plus crosswalks and covariates. Federal county-level data goes back to 1953; the other election families extend through 2026.

Python users

A lightweight Python loader is also available: gerda on PyPI (source: hhilbig/gerda-py). It exposes three functions — gerda.load(name), gerda.datasets(), and gerda.party_crosswalk(...) — and returns pandas DataFrames (or polars, optionally). Bundled covariate / Census merge helpers are not yet ported; use the R package for those.

pip install gerda
import gerda
df = gerda.load("federal_cty_harm")

Installation

# Install from CRAN
install.packages("gerda")

# Or install development version from GitHub
devtools::install_github("hhilbig/gerda")

Main Functions

Data Loading

Covariates (INKAR county-level, 1995–2022)

Census 2022 (Zensus, municipality-level)

Join Diagnostics

merged <- load_gerda_web("federal_cty_harm") %>%
  add_gerda_covariates(unmatched = "error")

gerda_join_diagnostics(merged)

Party Mapping

Usage Examples

library(gerda)

# List available datasets
gerda_data_list()

# Load harmonized municipal election data
municipal <- load_gerda_web("municipal_harm", verbose = TRUE)

# Load federal county data with socioeconomic covariates
federal_county <- load_gerda_web("federal_cty_harm") %>%
  add_gerda_covariates()

# View covariate definitions
gerda_covariates_codebook()

# Map party names to ParlGov
party_crosswalk(c("cdu_csu", "spd", "gruene"), "party_name_english")

Breaking changes in v0.8

federal_cty_unharm column names. The ags and year aliases, deprecated since v0.6, were removed in v0.8.0 as announced. load_gerda_web("federal_cty_unharm") now renames the upstream columns to county_code and election_year on load and prints a one-time message pointing existing code at the new names. These match the rest of the county-level datasets and work directly with add_gerda_covariates().

Two Census 2022 variables were renamed to match the bins Destatis actually publishes:

Old name (v0.7 and earlier) New name (v0.8.0 onward) Covers
share_50to64_census22 share_50to59_census22 ages 50–59
share_65plus_census22 share_60plus_census22 ages 60 and older

The underlying values never changed; only the names were wrong. Destatis groups ages 60–74 into a single bin, so true 50–64 and 65+ shares cannot be constructed from these tables. Code written against the old names will error rather than silently return the wrong age group, but any published results that relied on them describe different age ranges than their labels implied.

Documentation

Feedback

Feedback is welcome. Please email hhilbig@ucdavis.edu or open an issue on GitHub.