{"id":14068628,"url":"https://github.com/CorrelAid/datenguideR","last_synced_at":"2025-07-30T04:31:35.755Z","repository":{"id":55425777,"uuid":"193223065","full_name":"CorrelAid/datenguideR","owner":"CorrelAid","description":"R wrapper for the datengui.de GraphQL API to easily access German regional statistics","archived":false,"fork":false,"pushed_at":"2021-07-23T15:43:41.000Z","size":3686,"stargazers_count":26,"open_issues_count":13,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-04T09:39:43.765Z","etag":null,"topics":["api-wrapper","datenguide","german-language","graphql","regional-data","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CorrelAid.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-22T10:49:26.000Z","updated_at":"2024-11-10T19:59:21.000Z","dependencies_parsed_at":"2022-08-15T00:01:03.151Z","dependency_job_id":null,"html_url":"https://github.com/CorrelAid/datenguideR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CorrelAid/datenguideR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorrelAid%2FdatenguideR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorrelAid%2FdatenguideR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorrelAid%2FdatenguideR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorrelAid%2FdatenguideR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CorrelAid","download_url":"https://codeload.github.com/CorrelAid/datenguideR/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CorrelAid%2FdatenguideR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267809489,"owners_count":24147474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","datenguide","german-language","graphql","regional-data","rstats"],"created_at":"2024-08-13T07:06:18.835Z","updated_at":"2025-07-30T04:31:35.352Z","avatar_url":"https://github.com/CorrelAid.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n# datenguideR \u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.width = 6,\n  fig.height = 4,\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\n\n```\n\n\u003c!-- badges: start --\u003e\n[![Build_Status](https://travis-ci.org/CorrelAid/datenguideR.svg?branch=master)](https://travis-ci.org/CorrelAid/datenguideR)\n[![Codecov test coverage](https://codecov.io/gh/CorrelAid/datenguideR/branch/master/graph/badge.svg)](https://codecov.io/gh/CorrelAid/datenguideR?branch=master)\n[![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)\n[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.png?v=103)](https://github.com/ellerbrock/open-source-badges/)\n\u003c!-- badges: end --\u003e\n\nAccess and download German regional statistics from Datenguide \u003chttp://datengui.de\u003e. `datenguideR` provides a wrapper for their GraphQL API and also includes metadata for all available statistics and regions.\n\n**Overview**\n\n+ [Usage](https://github.com/CorrelAid/datenguideR#usage)\n+ [Examples](https://github.com/CorrelAid/datenguideR#examples)\n    + [Search meta data (`dg_search`)](https://github.com/CorrelAid/datenguideR#dg_search)\n    + [Main function (`dg_call`)](https://github.com/CorrelAid/datenguideR#dg_call)\n    + [Multiple regions (at once)](https://github.com/CorrelAid/datenguideR#multiple-regions-with-nuts_nr-or-lau_nr)\n    + [Plot data on maps (`dg_map`)](https://github.com/CorrelAid/datenguideR#dg_map)\n+ [Use Cases](https://github.com/CorrelAid/datenguideR#use-cases)\n+ [Credits and Acknowledgements](https://github.com/CorrelAid/datenguideR#credits-and-acknowledgements)\n+ [Code of Conduct](https://github.com/CorrelAid/datenguideR#code-of-conduct)\n\n## Usage\n\nFirst, install `datenguideR` from GitHub:\n\n```{r, eval=F}\ndevtools::install_github(\"CorrelAid/datenguideR\")\n```\n\nLoad package:\n\n```{r}\nlibrary(datenguideR)\n```\n\n\n## Examples\n\nGet IDs of all available NUTS-1 regions:\n\n```{r}\ndatenguideR::dg_regions %\u003e%\n  dplyr::filter(level == \"nuts1\") %\u003e%\n  knitr::kable()\n```\n\nGet all available meta data on statistics, substatistics, and parameters:\n\n```{r}\ndatenguideR::dg_descriptions\n```\n\n### `dg_search`\n\nYou can also use `dg_search` to look for a variable of interest. The function will match your string with any strings in the `dg_descriptions` data frame, returning only rows with those matches.\n\nLooking for variables where the string *\"vote\"* appears somewhere in the documentation:\n\n```{r}\ndg_search(\"vote\")\n```\n\nNote: Descriptions of variables are also available in English now! Translated via the [`googleLanguageR`](https://github.com/ropensci/googleLanguageR) package.\n\n```{r}\ndg_search(\"vote\") %\u003e% \n  dplyr::select(stat_name, dplyr::contains(\"_en\"))\n```\n\n### `dg_call`\n\nThe main function of the package is `dg_call`. It gives access to all API endpoints.\n\nSimply pick a statistic and put it into `dg_call()` (infos can be retrieved from `dg_descriptions`).\n\nFor example:\n\n - `stat_name`: AI0506 *(Wahlbeteiligung, Bundestagswahl)*\n - `region_id`: 11 (stands for Berlin)\n\n```{r}\ndg_call(region_id = \"11\",\n        year = 2017,\n        stat_name = \"AI0506\")\n\n\n\n```\n\n\n\nA slightly more complex call with substatistics:\n\n  - `stat_name`: BETR08 *(Landwirtschaftliche Betriebe mit Tierhaltung)*\n  - `substat_name`: TIERA8 *(Landwirtschaftliche Betriebe mit Viehhaltung)*\n  - `parameter`:\n    - TIERART2 *(Rinder)*\n    - TIERART3 *(Schweine)*\n    \n```{r}\n\ndg_call(region_id = \"11\", \n        year = c(2001, 2003, 2007), \n        stat_name = \"BETR08\", \n        substat_name = \"TIERA8\", \n        parameter = c(\"TIERART2\", \"TIERART3\")) \n```\n\nIf you give no parameters for a substat, it will default to return results for all of them.\n\n```{r}\ndg_call(region_id = \"11\", \n        year = c(2001, 2003, 2007), \n        stat_name =  \"BETR08\", \n        substat_name = \"TIERA8\") \n```\n\n\n### Multiple regions with `nuts_nr` or `lau_nr`\n\nInstead of specifying a `region_id` for individual Bundesland (state) data you can also use `nuts_nr` to receive data for *NUTS-1*, *NUTS-2* and *NUTS-3*.\n\nJust leave `region_id` blank and provide either a `nuts_nr` (or `lau_nr`) to get data for multiple regions at once.\n\n - `stat_name`: AI0506 *(Wahlbeteiligung, Bundestagswahl)*\n\n```{r}\ndg_call(nuts_nr = 1,\n        year = 2017,\n        stat_name = \"AI0506\")\n\n\n\n```\n\n  - `stat_name`: BETR08 *(Landwirtschaftliche Betriebe mit Tierhaltung)*\n  - `substat_name`: TIERA8 *(Landwirtschaftliche Betriebe mit Viehhaltung)*\n\n```{r}\ndg_call(nuts_nr = 1,\n        year = c(2001, 2003, 2007), \n        stat_name = \"BETR08\", \n        substat_name = \"TIERA8\") \n```\n\n  - `stat_name`: BAU018 *Total non-residential buildings*\n  - `substat_name`: BAUAHZ *Main Type of Heating*\n\n\t\n \n\n```{r}\ndg_call(nuts_nr = 1,\n        stat_name =  \"BAU018\",\n        substat_name = \"BAUAHZ\",\n        year = 2016)\n```\n\n\u003c!-- ```{r} --\u003e\n\u003c!-- dg_call(nuts_nr = 2,  --\u003e\n\u003c!--         stat_name = \"GEBWOR\",  --\u003e\n\u003c!--         substat_name = \"BAUAT2\") --\u003e\n\u003c!-- ``` --\u003e\n\n\u003c!-- # ```{r} --\u003e\n\u003c!-- # library(datenguideR) --\u003e\n\u003c!-- # debugonce(datenguideR:::add_substat_info) --\u003e\n\u003c!-- # dg_call(lau_nr = 1, parent_chr = 10041,  --\u003e\n\u003c!-- #         stat_name =  \"BAU018\", --\u003e\n\u003c!-- #         substat_name = \"BAUAHZ\",) --\u003e\n\u003c!-- # ``` --\u003e\n\n### `dg_map`\n\nYou can also use `dg_map` to plot retrieved data on a Germany map. This currently only supports NUTS-1 and NUTS-2. Arguments are (mostly) identical to `dg_call`.\n\n\n```{r}\ndg_map(nuts_nr = 1,\n        year = 2017,\n        stat_name = \"AI0506\")\n\n```\n\nThe output is a ggplot object and can be manipulated further.\n\n```{r}\ndg_map(nuts_nr = 1,\n        year = 2017,\n        stat_name = \"AI0506\") +\n  ggthemes::theme_map() +\n  ggplot2::scale_fill_viridis_c(\"Voter Turnout\") +\n  ggplot2::ggtitle(\"Voter Turnout in German Parliamentary Election (2017)\") +\n  ggplot2::theme(legend.position = \"right\")\n\n```\nYou can also return the data and use your own plotting functions with `return_data = TRUE`.\n\n```{r}\nturnout_dat \u003c- dg_map(nuts_nr = 1,\n        year = 2017,\n        stat_name = \"AI0506\",\n        return_data = T)\n\nturnout_dat\n\n```\n\n\n## Use Cases\n\nCheck out some use cases. For example here:\n\n+ [Correlaid Meetup - datenguideR workshop](https://github.com/TripLLL/weRnuts3)\n\n\n\n\n## Credits and Acknowledgements\n\ndatenguideR builds on the amazing work of [Datenguide](https://datengui.de/) and their [GraphQL API](https://github.com/datenguide/datenguide-api). We especially thank [Simon Jockers](https://twitter.com/sjockers), [Simon Wörpel](https://twitter.com/simonwoerpel), and [Christian Rijke](https://twitter.com/crijke) for their constructive feedback, helpful comments, and overall support while developing the package.\n\nThe data is retrieved via the Datenguide API from the German Federal Statistical Office and the statistical offices of the German states. Data being used via this package has to be credited according to the [Datenlizenz Deutschland – Namensnennung – Version 2.0](https://www.govdata.de/dl-de/by-2-0).\n\nThis package was created with [devtools](https://github.com/r-lib/devtools), [usethis](https://github.com/r-lib/usethis), and [roxygen2](https://github.com/r-lib/roxygen2). Continuous integration was done with [Travis CI](https://travis-ci.org/).\n\n\n## Code of Conduct\n\ndatenguideR is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorrelAid%2FdatenguideR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCorrelAid%2FdatenguideR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorrelAid%2FdatenguideR/lists"}