| Title: | District-Level German Police Crime Statistics |
|---|---|
| Description: | Access to the district (Kreis) tables of the German Police Crime Statistics ('Polizeiliche Kriminalstatistik', PKS) published by the Bundeskriminalamt, from 2003 onwards. Data come from versioned, validated releases of the 'pksR-data' pipeline, either as published or harmonized to a common territorial boundary and offence classification. Downloads are cached and checked against SHA-256 checksums; rates can be recomputed after harmonization, panels validated, and data releases cited. |
| Authors: | Ömer Furkan Çoban [aut, cre, cph] (ORCID: <https://orcid.org/0009-0005-3623-7178>) |
| Maintainer: | Ömer Furkan Çoban <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-22 01:17:54 UTC |
| Source: | https://github.com/cran/pksR |
Changes in the PKS that make values before and after a year incomparable or only partly comparable: new offence definitions, key changes, changes in the population denominator, boundary reforms and others. Check these before interpreting changes over time. Real shocks such as the Covid-19 pandemic (2020 and 2021) are not breaks: they change recorded crime, not how it is measured.
pks_breaks()pks_breaks()
The table is a snapshot of known_breaks.csv of pksR-data that ships with
the package; each data release contains its own copy.
A tibble with break_id, first_year, offence_key (keys
separated by ;, empty when all keys are affected), variable, type,
comparable (yes, likely, unknown, no), description,
evidence and status.
Bekannte methodische Brüche der PKS: neue Definitionen, geänderte
Schlüssel, geänderte Bezugsbevölkerung, Gebietsreformen und andere.
comparable gibt an, ob Werte vor und nach dem Jahr vergleichbar sind
(yes, likely, unknown, no). Vor jeder Zeitreihe prüfen.
Echte Schocks wie die Covid-19-Pandemie (2020 und 2021) sind keine
Brüche: Sie verändern die erfasste Kriminalität, nicht ihre Messung.
Other metadata:
pks_offences()
b <- pks_breaks() b[b$comparable == "no", c("first_year", "offence_key", "description")]b <- pks_breaks() b[b$comparable == "no", c("first_year", "offence_key", "description")]
Deletes cached release files, for all data versions or only for the ones given. The files are downloaded again when they are next needed.
pks_cache_clear(version = NULL, ask = interactive())pks_cache_clear(version = NULL, ask = interactive())
version |
Character vector of data versions to remove, such as
|
ask |
Ask for confirmation before deleting. Defaults to |
The removed files as a tibble like pks_cache_info(), invisibly.
Löscht Dateien aus dem Cache, für alle oder für die angegebenen Datenversionen. In interaktiven Sitzungen wird vorher nachgefragt.
Other cache:
pks_cache_info()
# A temporary cache, so the example leaves your own cache alone old <- Sys.getenv("R_USER_CACHE_DIR", NA) Sys.setenv(R_USER_CACHE_DIR = tempfile()) pks_cache_clear(ask = FALSE) if (is.na(old)) Sys.unsetenv("R_USER_CACHE_DIR") else Sys.setenv(R_USER_CACHE_DIR = old)# A temporary cache, so the example leaves your own cache alone old <- Sys.getenv("R_USER_CACHE_DIR", NA) Sys.setenv(R_USER_CACHE_DIR = tempfile()) pks_cache_clear(ask = FALSE) if (is.na(old)) Sys.unsetenv("R_USER_CACHE_DIR") else Sys.setenv(R_USER_CACHE_DIR = old)
Lists the release files that pks_get() and pks_manifest() have stored
in the cache directory, tools::R_user_dir("pksR", "cache").
pks_cache_info()pks_cache_info()
A tibble with one row per cached file: version, file, bytes
and modified. The cache directory is attached as attribute path.
Listet die im Cache (tools::R_user_dir("pksR", "cache")) gespeicherten
Dateien, je Datenversion.
Other cache:
pks_cache_clear()
pks_cache_info()pks_cache_info()
Work with these data should cite the package, the data release used (each release is versioned and never changes) and the original sources. The source data keep their terms of reuse: the PKS tables of the Bundeskriminalamt and the BBSR crosswalk are licensed under the Data licence Germany, attribution, version 2.0 (dl-de/by-2-0, https://www.govdata.de/dl-de/by-2-0), which requires naming the source and stating that the data were changed; the Destatis municipality directory may be reproduced with a source note.
pks_cite(version = "latest")pks_cite(version = "latest")
version |
Data version such as |
Each data release is archived on Zenodo. The data release entry carries the DOI of its version, read from the release notes; until Zenodo has archived a new version, it carries the concept DOI, which resolves to the latest version.
A utils::bibentry() object with one entry each for the package,
the data release, the PKS, the BBSR crosswalk and the Destatis
municipality directory. Print it, or convert it with format(x, "bibtex").
Zitierangaben für das Paket, die verwendete Datenveröffentlichung und die
Quellen: die PKS des Bundeskriminalamts und der Umsteigeschlüssel des BBSR
(beide Datenlizenz Deutschland, Namensnennung, Version 2.0, die die Nennung
der Quelle und einen Hinweis auf Veränderungen verlangt) sowie das
Gemeindeverzeichnis von Destatis. Jede Datenveröffentlichung ist auf
Zenodo archiviert; der Eintrag trägt die DOI ihrer Version aus den
Release-Notizen oder, solange Zenodo sie noch nicht archiviert hat, die
Konzept-DOI. Ergebnis: ein utils::bibentry()-Objekt;
format(x, "bibtex") liefert BibTeX.
Other releases:
pks_manifest(),
pks_versions()
pks_cite() format(pks_cite(), "bibtex")pks_cite() format(pks_cite(), "bibtex")
Districts that were split had to be divided between their successors, by
population (default) or by area. pks_compare_weights() puts both
versions of a harmonized panel side by side, so you can see where and how
much a result depends on that choice. Merged and unchanged districts are
the same under both weights.
pks_compare_weights(data, other = NULL)pks_compare_weights(data, other = NULL)
data |
A harmonized tibble from |
other |
|
A tibble with one row per year, district and offence key:
year, ags, region_name, offence_key, estimated (split in at
least one of the two panels), cases_population, cases_area,
difference (area minus population), relative_difference
(difference / cases_population), hz_population and hz_area
(recomputed with pks_rates()). A message summarizes how many rows
differ.
Stellt eine harmonisierte Tabelle mit Bevölkerungs- und mit
Flächengewichten nebeneinander. Die Gewichte unterscheiden sich nur bei
geteilten Kreisen; so lässt sich prüfen, wie stark ein Ergebnis von dieser
Annahme abhängt. other kann die Tabelle mit den anderen Gewichten
liefern, sonst wird sie mit denselben Jahren, Straftaten, demselben
Gebietsstand und derselben Datenversion geladen.
Other analysis:
pks_rates(),
pks_validate()
d <- pks_get(years = 2005:2010, offence = "total") w <- pks_compare_weights(d) w[abs(w$relative_difference) > 0.01, ]d <- pks_get(years = 2005:2010, offence = "total") w <- pks_compare_weights(d) w[abs(w$relative_difference) > 0.01, ]
A subset of the harmonized panel of pksR-data that ships with the package, for
examples, tests and vignettes without internet access: five districts,
two offence keys and the years 2019 to 2025, harmonized to the 2025
boundary with population weights, built from pksR-data commit 9b6985d
(data-raw/example.R), not from a data release, so data_version is
"example". Source: PKS Bundeskriminalamt,
Datenlizenz Deutschland, Namensnennung, Version 2.0; changed (harmonized)
by pksR-data.
pks_example()pks_example()
A tibble in the format of pks_get().
Ein kleines Beispielpanel, das mit dem Paket ausgeliefert wird: fünf
Kreise, zwei Straftatenschlüssel und die Jahre 2019 bis 2025, harmonisiert
auf den Gebietsstand 2025. Es stammt aus einem lokalen Lauf von pksR-data,
nicht aus einer Datenveröffentlichung (data_version = "example"). Quelle:
PKS Bundeskriminalamt, Datenlizenz Deutschland, Namensnennung, Version 2.0;
verändert (harmonisiert).
Other data:
pks_get()
pks_example()pks_example()
Downloads the district (Kreis) tables of the German Police Crime Statistics (PKS) from a versioned data release, as published by the Bundeskriminalamt or harmonized to one territorial boundary and offence classification. Files are cached and checked against the SHA-256 checksums of the release manifest.
pks_get( years = NULL, offence = NULL, harmonize_to = "latest", weights = c("population", "area"), version = "latest", source = c("release", "bka"), cache = TRUE, lang = NULL )pks_get( years = NULL, offence = NULL, harmonize_to = "latest", weights = c("population", "area"), version = "latest", source = c("release", "bka"), cache = TRUE, lang = NULL )
years |
Integer vector of reporting years, or |
offence |
Offences to return, or |
harmonize_to |
Target boundary year (Gebietsstand). |
weights |
Weights for districts that were split: |
version |
Data version such as |
source |
|
cache |
Keep downloaded files in the cache (default |
lang |
Language of the offence labels in column |
A tibble with one row per year, district (ags) and offence key.
Columns are described in vignette("pksR"). Attributes:
data_version, retrieved_at, boundary_year, weights and
source_urls.
Lädt die Kreistabellen der Polizeilichen Kriminalstatistik (PKS) aus einer versionierten Datenveröffentlichung, wie vom Bundeskriminalamt veröffentlicht oder auf einen Gebietsstand und eine Straftatenzuordnung harmonisiert. Jede Datei wird gegen die SHA-256-Prüfsumme des Manifests geprüft und im Cache abgelegt.
years: Berichtsjahre, NULL für alle.
offence: Straftaten als Schlüssel ("435*00"), Kurzname auf Deutsch oder
Englisch ("wohnungseinbruch", "residential_burglary"), vollständige Bezeichnung oder
Teil einer Bezeichnung ("einbruch"). Groß- und Kleinschreibung,
Leerzeichen und Umlaute spielen keine Rolle; eine genaue Übereinstimmung hat
Vorrang. Übersicht: pks_offences().
harmonize_to: "latest" (Gebietsstand der Veröffentlichung), ein Jahr
(Harmonisierung nur vorwärts) oder NULL (wie veröffentlicht).
weights: Gewichtung geteilter Kreise, "population" oder "area".
version: Datenversion, etwa "2026.1", oder "latest".
lang: Sprache der Bezeichnungen und Meldungen, "de" oder "en";
Voreinstellung options(pksR.lang), sonst die Sprache der R-Sitzung.
Ergebnis: ein Tibble mit einer Zeile je Jahr, Kreis und Straftatenschlüssel
und den Attributen data_version, retrieved_at, boundary_year, weights
und source_urls.
Other data:
pks_example()
# Total offences, harmonized to the latest boundary total <- pks_get(offence = "total") # Theft in total and both burglary keys, German labels theft <- pks_get(offence = c("diebstahl", "einbruch"), lang = "de") # As published by the BKA, two years published <- pks_get(years = 2024:2025, harmonize_to = NULL)# Total offences, harmonized to the latest boundary total <- pks_get(offence = "total") # Theft in total and both burglary keys, German labels theft <- pks_get(offence = c("diebstahl", "einbruch"), lang = "de") # As published by the BKA, two years published <- pks_get(years = 2024:2025, harmonize_to = NULL)
The manifest describes one data release: when and from which pipeline commit it was built, the years and target boundary year it covers, the validation result, and every file with its SHA-256, size and number of rows.
pks_manifest(version = "latest")pks_manifest(version = "latest")
version |
Data version such as |
A tibble with one row per release file (name, sha256, bytes,
rows). The other manifest fields (data_version, created_at,
pipeline_commit, target_boundary_year, years, validation,
notes, license, attribution, ...) are attached as attribute
manifest.
Liest das Manifest einer Datenveröffentlichung: wann und mit welchem
Stand der Pipeline sie erstellt wurde, welche Jahre und welchen Gebietsstand
sie abdeckt, das Ergebnis der Prüfung und jede Datei mit Prüfsumme, Größe und
Zeilenzahl. Ergebnis: ein Tibble der Dateien, die übrigen Angaben im Attribut
manifest.
Other releases:
pks_cite(),
pks_versions()
m <- pks_manifest() attr(m, "manifest")$target_boundary_yearm <- pks_manifest() attr(m, "manifest")$target_boundary_year
The district tables contain a selected subset of offence keys
(Straftatenschluessel). The harmonized keys used by pks_get() are listed
here with a short name and a label in German or English, their parent key
and the years they cover. Mappings and names marked status = "draft"
have not been reviewed yet.
pks_offences(pattern = NULL, lang = NULL)pks_offences(pattern = NULL, lang = NULL)
pattern |
Optional text to search for in the keys, short names and
labels of both languages. Capitals, spaces and umlauts do not matter, so
|
lang |
Language of the |
The table is a snapshot of the offence map of pksR-data that ships with the
package, so it works offline. Each data release also contains its own
offence_map.csv, which pks_get() uses.
A tibble with offence_key, name (the short name accepted by
pks_get(offence = )), label, parent_key, valid_from, valid_to,
status and notes.
Listet die harmonisierten Straftatenschlüssel mit Kurzname, Bezeichnung
auf Deutsch oder Englisch, übergeordnetem Schlüssel und Gültigkeitsjahren.
pattern durchsucht Schlüssel, Kurznamen und Bezeichnungen beider Sprachen;
lang wählt die Sprache der Spalten name und label. Zuordnungen mit
status = "draft" sind noch nicht geprüft.
Other metadata:
pks_breaks()
pks_offences("Diebstahl", lang = "de") pks_offences("theft", lang = "en")pks_offences("Diebstahl", lang = "de") pks_offences("theft", lang = "en")
Rates cannot be harmonized: when districts are merged or split, the
published frequency (Haeufigkeitszahl, cases per 100,000 inhabitants) and
clearance rate of the old districts do not carry over. pks_rates()
recomputes them from the counts, with the population of the data or one
you supply.
pks_rates(data, population = NULL, per = 1e+05)pks_rates(data, population = NULL, per = 1e+05)
data |
A tibble from |
population |
|
per |
Rate denominator for column |
Cases come from cases, or from cases_derived in the PDF years, where
the BKA printed only rates. The clearance rate is 0 where cases are 0, as
in the BKA tables.
The BKA divides by the population of 31 December of the year before, on
the census base of its time: older registers until 2012, Zensus 2011 for
2013 to 2023, Zensus 2022 from 2024. Rates therefore jump in 2013 and 2024
without any change in crime (see pks_breaks()). With population = "corrected" every year uses the census-corrected population of the BBSR
(INKAR), at the same date and on the same boundary, so rates are on one
base over the whole period.
data with hz (cases per 100,000) and clearance_rate
recomputed, and a new column rate (cases per per). The population
used is in column rate_population.
Berechnet Häufigkeitszahl (Fälle je 100.000 Einwohner) und
Aufklärungsquote neu aus den Fallzahlen, etwa nach einer Harmonisierung, bei
der veröffentlichte Quoten nicht übertragen werden können. population kann
eine eigene Einwohnerzahl je Jahr und Kreis liefern; per setzt den Nenner
der neuen Spalte rate. Das BKA teilt durch die Einwohnerzahl zum 31.12.
des Vorjahres auf der Zensusbasis ihrer Zeit, daher springen die Quoten 2013
und 2024. population = "corrected" nutzt für alle Jahre die
zensuskorrigierte Einwohnerzahl des BBSR (INKAR) und macht die Quoten über
den ganzen Zeitraum vergleichbar.
Other analysis:
pks_compare_weights(),
pks_validate()
d <- pks_example() pks_rates(d, per = 1000)[, c("year", "ags", "cases", "hz", "rate")] # One census base for all years pks_rates(d, population = "corrected")[, c("year", "ags", "hz", "rate_population")]d <- pks_example() pks_rates(d, per = 1000)[, c("year", "ags", "cases", "hz", "rate")] # One census base for all years pks_rates(d, population = "corrected")[, c("year", "ags", "hz", "rate_population")]
Runs the consistency checks of the pksR-data validation gate that need
only the panel itself: schema, uniqueness, coverage and plausibility. Use
it after filtering, joining or editing data from pks_get(). The checks of
national totals and conservation need the national tables and run in the
pipeline before every release.
pks_validate(data)pks_validate(data)
data |
A tibble from |
Checks:
schema: the columns of the data as published or harmonized, with their
types.
uniqueness: one row per year, ags and offence_key.
city_states: Berlin (11000) and Hamburg (02000) present in every
year.
coverage: harmonized data have the same districts in every year
(balanced panel).
counts: no negative counts, and attempts not above cases.
population: the median district population per year lies between
50,000 and 400,000 (a warning otherwise).
A tibble with one row per check: check, status (pass,
warn or fail), problems (number of offending rows or years) and
details.
Prüft ein Panel auf Schema, Eindeutigkeit (eine Zeile je Jahr, Kreis und
Schlüssel), Vorhandensein von Berlin und Hamburg in jedem Jahr, gleichen
Kreisbestand in harmonisierten Daten, keine negativen Zahlen, nicht mehr
Versuche als Fälle und plausible Einwohnerzahlen. Ergebnis: ein Tibble mit
einer Zeile je Prüfung und dem Status pass, warn oder fail.
Other analysis:
pks_compare_weights(),
pks_rates()
pks_validate(pks_example())pks_validate(pks_example())
Data releases are versioned and never change; a correction is published as
a new version. Versions are named <year>.<n>, for example "2026.1".
pks_versions()pks_versions()
A tibble with one row per data release, newest first: version,
tag, published_at, files, url and doi (Zenodo DOI of the
version, NA until Zenodo has archived it).
Listet die veröffentlichten Datenversionen, die neueste zuerst. Eine
Veröffentlichung ändert sich nie; Korrekturen erscheinen als neue Version.
Die Spalte doi enthält die Zenodo-DOI der Version.
Other releases:
pks_cite(),
pks_manifest()
pks_versions()pks_versions()