class: center, middle, inverse, title-slide #
Hacking Germany’s Official Statistics with datenguideR ### Lisa Hehnke
@DataPlanes
Fabio Votta
@favstats
Vroni Grupp
@vgeodata
Slides available at:
dg-berlinR.netlify.com
2020-02-05 --- <style> .onehundredtwenty { font-size: 120%; } <style> .ninety { font-size: 90%; } .eightyfive { font-size: 85%; } .eighty { font-size: 80%; } .seventyfive { font-size: 75%; } .seventy { font-size: 70%; } .sixty { font-size: 60%; } .fifty { font-size: 50%; } </style> ### What's ahead? 1. Introduction to the datenguideR *infrastructure* 2. Main functions of datenguideR and examples (`dg_call`) 3. Plotting function (`dg_map`) 4. Hackathon! -- ![](https://media.giphy.com/media/Lm62AlSEQqhimpM59W/giphy.gif) --- .pull-left[ ### How to `datenguideR` First install `datenguideR` from GitHub (not yet on CRAN) ] .pull-right[ <img src="images/logo3.png" width="100" height="120" style="display: block; margin: auto 0 auto auto;" /> ] ```r devtools::install_github("CorrelAid/datenguideR") ``` -- ![](images/not_a_trap.png) --- class: center, middle, inverse ### Admiral Ackbar says ![](https://media1.tenor.com/images/ead2e2345aba59ac4c09a1990c35afdd/tenor.gif?itemid=8125029) --- .pull-left[ ### How to `datenguideR` First install `datenguideR` from GitHub (not yet on CRAN) ] .pull-right[ <img src="images/logo3.png" width="100" height="120" style="display: block; margin: auto 0 auto auto;" /> ] ```r devtools::install_github("CorrelAid/datenguideR") ``` ![](images/its_a_trap.png) --- .pull-left[ ### How to `datenguideR` Functions start with `dg_*` ] .pull-right[ <img src="images/logo3.png" width="100" height="120" style="display: block; margin: auto 0 auto auto;" /> ] -- The `rOpenSci Package guide` states that: > Functions and arguments naming should be chosen to work together to form a common, logical programming API that is easy to read, and auto-complete. This `object_verb` scheme: + helps avoid namespace conflicts with packages that may have similar verbs + makes code readable and easy to auto-complete -- In the following we will learn about: + `dg_descriptions`: Meta data + `dg_search`: Search Meta data + `dg_call`: Make API Calls + `dg_map`: Plot Maps --- ### Metadata with `dg_descriptions` Get all available meta data on statistics, substatistics, and parameters: ```r datenguideR::dg_descriptions ``` ``` ## # A tibble: 3,419 x 11 ## stat_name stat_description stat_descriptio… substat_name ## <chr> <chr> <chr> <chr> ## 1 AENW01 Entsorgte/behan… "**Entsorgte/be… <NA> ## 2 AENW02 Abgelagerte Abf… "**Abgelagerte … <NA> ## 3 AENW03 Entsorg.u.Behan… "**Entsorg.u.Be… <NA> ## 4 AENW04 Entsorgte/behan… "**Entsorgte/be… <NA> ## 5 AENW05 Abgelagerte Abf… "**Abgelagerte … <NA> ## 6 AENW06 Entsorg.u.Behan… "**Entsorg.u.Be… <NA> ## 7 AEW001 Entsorgungs- un… "**Entsorgungs-… <NA> ## 8 AEW001 Entsorgungs- un… "**Entsorgungs-… EBANL1 ## 9 AEW001 Entsorgungs- un… "**Entsorgungs-… EBANL1 ## 10 AEW001 Entsorgungs- un… "**Entsorgungs-… EBANL1 ## # … with 3,409 more rows, and 7 more variables: substat_description <chr>, ## # param_name <chr>, param_description <chr>, stat_description_en <chr>, ## # stat_description_full_en <chr>, substat_description_en <chr>, ## # param_description_en <chr> ``` --- ### Metadata with `dg_descriptions` Variables are hierarchically organized on **three levels**: `stat`, `substat` and `param`. A `stat` may or may not have any `substats` and a `substat` may or not have any `params`. It completely depends on the variable. ```r stat level ¦--stat_name ¦--stat_description ¦--stat_description_en ¦--stat_description_full ¦--stat_description_full_en ¦ °--substat level ¦--substat_name ¦--substat_description ¦--substat_description_en ¦ °--param level ¦--param_name ¦--param_description ¦--param_description_en ``` --- class: center, middle, inverse ## Confused? ![](https://media3.giphy.com/media/1oJLpejP9jEvWQlZj4/giphy.gif) ### Let's consider an example --- ### Metadata with `dg_descriptions` Let's consider the example of statistics on new German citizens (`BEV008`) ```r stat level ¦--stat_name ¦--stat_description ¦--stat_description_en ¦--stat_description_full ¦--stat_description_full_en ¦ °--substat level ¦--substat_name ¦--substat_description ¦--substat_description_en ¦ °--param level ¦--param_name ¦--param_description ¦--param_description_en ``` --- ### Metadata with `dg_descriptions` Let's consider the example of statistics on new German citizens (`BEV008`) ```r stat level ¦--stat_name: BEV008 ¦--stat_description: Einbürgerungen von Ausländern ¦--stat_description_en: Naturalizations of Foreigners ¦--stat_description_full: ... ¦--stat_description_full_en: ... ¦ °--substat level ¦--substat_name: STAKNW ¦--substat_description: Kontinente (einschl. staatenlos etc.) ¦--substat_description_en: Continents (Including Stateless Etc.) ¦ °--param level ¦--param_name: ST997 ¦--param_description: Staatenlos, unbekannt, ungeklärt, ohne Angabe ¦--param_description_en: Stateless, Unknown, Unsettled, without Information ``` --- ### Metadata with `dg_descriptions` First, there is the `stat_*` level. ```r *stat level *¦--stat_name: BEV008 *¦--stat_description: Einbürgerungen von Ausländern *¦--stat_description_en: Naturalizations of Foreigners *¦--stat_description_full: ... *¦--stat_description_full_en: ... ¦ °--substat level ¦--substat_name: STAKNW ¦--substat_description: Kontinente (einschl. staatenlos etc.) ¦--substat_description_en: Continents (Including Stateless Etc.) ¦ °--param level ¦--param_name: ST997 ¦--param_description: Staatenlos, unbekannt, ungeklärt, ohne Angabe ¦--param_description_en: Stateless, Unknown, Unsettled, without Information ``` --- ### Metadata with `dg_descriptions` The variable `stat_description_full_en` includes a long English description of a given statistic (written up in Markdown): -- .seventyfive[ ** Naturalizations of foreigners ** * from GENESIS statistics "Naturalization Statistics" 12511) * Naturalizations of foreigners Explanation for the following statistics: 12511 Naturalization statistics Conceptual content: Naturalizations Naturalizations are the total number of naturalizations of foreigners carried out by German authorities in Germany and abroad in the course of the reporting year. In the case of naturalization, a foreigner is granted German citizenship by handing in a certificate of naturalization. For this, an application must be made and the foreign person concerned must meet certain requirements. Naturalizations occur in the majority on the basis of the Citizenship Act (StAG), but also by other legal bases that mostly regulate old and reparation cases. The naturalization statistics report on naturalizations carried out in Germany and abroad by German authorities in the course of the reporting year according to their previous nationality, legal grounds for naturalization, length of stay in the federal territory, gender, age, marital status and according to continuing or discontinued citizenship. The regional proof of naturalization cases relates to the place of residence of the naturalized person at the time of naturalization. The data does not include the acquisition of German citizenship by the birth of children of foreign parents born in Germany (pursuant to Section 4 (3) StAG). Conceptual content: foreigners Foreigners are all persons who do not have German citizenship, ie are not German within the meaning of Article 116 (1) of the Basic Law (GG). Stateless persons and people with unresolved citizenships also belong to this group of people. ] --- ### Metadata with `dg_descriptions` Next, there is the `substat_*` level. In the example, the substatistic splits new statistics by continent of origin (`STAKNW`). ```r stat level ¦--stat_name: BEV008 ¦--stat_description: Einbürgerungen von Ausländern ¦--stat_description_en: Naturalizations of Foreigners ¦--stat_description_full: ... ¦--stat_description_full_en: ... ¦ *°--substat level * ¦--substat_name: STAKNW * ¦--substat_description: Kontinente (einschl. staatenlos etc.) * ¦--substat_description_en: Continents (Including Stateless Etc.) ¦ °--param level ¦--param_name: ST997 ¦--param_description: Staatenlos, unbekannt, ungeklärt, ohne Angabe ¦--param_description_en: Stateless, Unknown, Unsettled, without Information ``` Other possible examples of a substat for `BEV008` is the statistic split up by age groups (`ALTX04`) or Length of Stay (`AUFDA1`). --- ### Metadata with `dg_descriptions` Next, there is the `param_*` level. In the example, we use `ST997` which queries new citizens who were "stateless" or have unknown origins. ```r stat level ¦--stat_name: BEV008 ¦--stat_description: Einbürgerungen von Ausländern ¦--stat_description_en: Naturalizations of Foreigners ¦--stat_description_full: ... ¦--stat_description_full_en: ... ¦ °--substat level ¦--substat_name: STAKNW ¦--substat_description: Kontinente (einschl. staatenlos etc.) ¦--substat_description_en: Continents (Including Stateless Etc.) ¦ * °--param level * ¦--param_name: ST997 * ¦--param_description: Staatenlos, unbekannt, ungeklärt, ohne Angabe * ¦--param_description_en: Stateless, Unknown, Unsettled, without Information ``` --- class: center, middle, inverse ## You might be thinking: ![](https://media1.tenor.com/images/4ef9869087411906c87241c3b985941c/tenor.gif?itemid=7666363) ### Don't worry, that's why we build `dg_search()` --- ### How to use `dg_search` `dg_search` matches your string with any variable in `dg_descriptions`, returning only rows with those matches. Looking for variables where the string *"vote"* appears somewhere in the documentation: ```r dg_search("vote") ``` ``` ## # A tibble: 90 x 5 ## stat_name stat_descriptio… stat_descriptio… substat_descrip… ## <chr> <chr> <chr> <chr> ## 1 AI0501 Second Vote Sha… "** CDU / CSU s… <NA> ## 2 AI0502 SPD Second Vote… "** SPD second … <NA> ## 3 AI0503 FDP Second Vote… "** Second vote… <NA> ## 4 AI0504 Second Vote Sha… "** GREEN secon… <NA> ## 5 AI0505 Second Vote Sha… "** Second vote… <NA> ## 6 AI0506 Voter Turnout, … "** Voter turno… <NA> ## 7 AI0601 CDU / CSU, Euro… "** CDU / CSU v… <NA> ## 8 AI0602 SPD Vote Share,… "** SPD vote sh… <NA> ## 9 AI0603 FDP Share of Vo… "** FDP vote sh… <NA> ## 10 AI0604 Share of Votes … "** GREEN share… <NA> ## # … with 80 more rows, and 1 more variable: param_description_en <chr> ``` --- ### How to `datenguideR` Get Region IDs of all available NUTS-1 regions with `dg_regions`: ```r datenguideR::dg_regions %>% dplyr::filter(level == "nuts1") ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["id"],"name":[1],"type":["chr"],"align":["left"]},{"label":["name"],"name":[2],"type":["chr"],"align":["left"]},{"label":["level"],"name":[3],"type":["chr"],"align":["left"]},{"label":["parent"],"name":[4],"type":["chr"],"align":["left"]}],"data":[{"1":"01","2":"Schleswig-Holstein","3":"nuts1","4":"DG"},{"1":"02","2":"Hamburg","3":"nuts1","4":"DG"},{"1":"03","2":"Niedersachsen","3":"nuts1","4":"DG"},{"1":"04","2":"Bremen","3":"nuts1","4":"DG"},{"1":"05","2":"Nordrhein-Westfalen","3":"nuts1","4":"DG"},{"1":"06","2":"Hessen","3":"nuts1","4":"DG"},{"1":"07","2":"Rheinland-Pfalz","3":"nuts1","4":"DG"},{"1":"08","2":"Baden-Württemberg","3":"nuts1","4":"DG"},{"1":"09","2":"Bayern","3":"nuts1","4":"DG"},{"1":"10","2":"Saarland","3":"nuts1","4":"DG"},{"1":"11","2":"Berlin","3":"nuts1","4":"DG"},{"1":"12","2":"Brandenburg","3":"nuts1","4":"DG"},{"1":"13","2":"Mecklenburg-Vorpommern","3":"nuts1","4":"DG"},{"1":"14","2":"Sachsen","3":"nuts1","4":"DG"},{"1":"15","2":"Sachsen-Anhalt","3":"nuts1","4":"DG"},{"1":"16","2":"Thüringen","3":"nuts1","4":"DG"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- class: center, middle, inverse # `dg_call` ![](https://shityoucanafford.com/wp-content/uploads/2017/11/horse-head-mask-office-min.jpg) ## The main work horse of `datenguideR` --- ### How to use `dg_call` Main arguments of `dg_call`: <br> <table class='gmisc_table' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' > <thead> <tr> <th style='border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>arguments</th> <th style='border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>description</th> </tr> </thead> <tbody> <tr> <td style='text-align: center;'>region_id</td> <td style='text-align: center;'>The ID of a specific region</td> </tr> <tr> <td style='text-align: center;'>stat_name</td> <td style='text-align: center;'>Main statistic</td> </tr> <tr> <td style='text-align: center;'>substat_name</td> <td style='text-align: center;'>Sub-statistic</td> </tr> <tr> <td style='text-align: center;'>parameter</td> <td style='text-align: center;'>Parameter<br>Defaults to all</td> </tr> <tr> <td style='text-align: center;'>year</td> <td style='text-align: center;'>Year(s)</td> </tr> <tr> <td style='text-align: center;'>nuts_nr</td> <td style='text-align: center;'>NUTS level</td> </tr> <tr> <td style='text-align: center;'>lau_nr</td> <td style='text-align: center;'>LAU level</td> </tr> <tr> <td style='border-bottom: 2px solid grey; text-align: center;'>full_descriptions</td> <td style='border-bottom: 2px solid grey; text-align: center;'>Full descriptions<br>Defaults to `FALSE`</td> </tr> </tbody> </table> --- ### How to use `dg_call` ```r dg_call(region_id = 11, # 11 is Berlin (see dg_regions) year = 2017, # Specify Year stat_name = "BEV008", # Stats on New Citizens substat_name = "STAKNW", # By Continent parameter = "GESAMT") # All categories summed ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["id"],"name":[1],"type":["chr"],"align":["left"]},{"label":["name"],"name":[2],"type":["chr"],"align":["left"]},{"label":["year"],"name":[3],"type":["int"],"align":["right"]},{"label":["STAKNW"],"name":[4],"type":["chr"],"align":["left"]},{"label":["value"],"name":[5],"type":["int"],"align":["right"]},{"label":["GENESIS_source"],"name":[6],"type":["chr"],"align":["left"]},{"label":["GENESIS_source_nr"],"name":[7],"type":["chr"],"align":["left"]},{"label":["stat_name"],"name":[8],"type":["chr"],"align":["left"]},{"label":["stat_description"],"name":[9],"type":["chr"],"align":["left"]},{"label":["substat_name"],"name":[10],"type":["chr"],"align":["left"]},{"label":["substat_description"],"name":[11],"type":["chr"],"align":["left"]},{"label":["param_description"],"name":[12],"type":["chr"],"align":["left"]},{"label":["stat_description_en"],"name":[13],"type":["chr"],"align":["left"]},{"label":["substat_description_en"],"name":[14],"type":["chr"],"align":["left"]},{"label":["param_description_en"],"name":[15],"type":["chr"],"align":["left"]}],"data":[{"1":"11","2":"Berlin","3":"2017","4":"GESAMT","5":"6479","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"STAKNW","11":"Kontinente (einschl. staatenlos etc.)","12":"Gesamt","13":"Naturalizations of Foreigners","14":"Continents (Including Stateless Etc.)","15":"Total"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- ### How to use `dg_call` ```r dg_call(nuts_nr = 1, # NUTS-1 year = 2017, # Specify Year stat_name = "BEV008", # Stats on New Citizens substat_name = "STAKNW", # By Continent parameter = "GESAMT") # All categories summed ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["id"],"name":[1],"type":["chr"],"align":["left"]},{"label":["year"],"name":[2],"type":["int"],"align":["right"]},{"label":["STAKNW"],"name":[3],"type":["chr"],"align":["left"]},{"label":["value"],"name":[4],"type":["int"],"align":["right"]},{"label":["name"],"name":[5],"type":["chr"],"align":["left"]},{"label":["GENESIS_source"],"name":[6],"type":["chr"],"align":["left"]},{"label":["GENESIS_source_nr"],"name":[7],"type":["chr"],"align":["left"]},{"label":["stat_name"],"name":[8],"type":["chr"],"align":["left"]},{"label":["stat_description"],"name":[9],"type":["chr"],"align":["left"]},{"label":["substat_description"],"name":[10],"type":["chr"],"align":["left"]},{"label":["param_description"],"name":[11],"type":["chr"],"align":["left"]},{"label":["stat_description_en"],"name":[12],"type":["chr"],"align":["left"]},{"label":["substat_description_en"],"name":[13],"type":["chr"],"align":["left"]},{"label":["param_description_en"],"name":[14],"type":["chr"],"align":["left"]},{"label":["year_id"],"name":[15],"type":["chr"],"align":["left"]}],"data":[{"1":"10","2":"2017","3":"GESAMT","4":"1188","5":"Saarland","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_10"},{"1":"11","2":"2017","3":"GESAMT","4":"6479","5":"Berlin","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_11"},{"1":"12","2":"2017","3":"GESAMT","4":"765","5":"Brandenburg","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_12"},{"1":"13","2":"2017","3":"GESAMT","4":"526","5":"Mecklenburg-Vorpommern","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_13"},{"1":"14","2":"2017","3":"GESAMT","4":"1560","5":"Sachsen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_14"},{"1":"15","2":"2017","3":"GESAMT","4":"734","5":"Sachsen-Anhalt","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_15"},{"1":"16","2":"2017","3":"GESAMT","4":"701","5":"Thüringen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_16"},{"1":"01","2":"2017","3":"GESAMT","4":"2714","5":"Schleswig-Holstein","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_01"},{"1":"02","2":"2017","3":"GESAMT","4":"5608","5":"Hamburg","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_02"},{"1":"03","2":"2017","3":"GESAMT","4":"8785","5":"Niedersachsen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_03"},{"1":"04","2":"2017","3":"GESAMT","4":"1449","5":"Bremen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_04"},{"1":"05","2":"2017","3":"GESAMT","4":"27381","5":"Nordrhein-Westfalen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_05"},{"1":"06","2":"2017","3":"GESAMT","4":"11496","5":"Hessen","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_06"},{"1":"07","2":"2017","3":"GESAMT","4":"5881","5":"Rheinland-Pfalz","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_07"},{"1":"08","2":"2017","3":"GESAMT","4":"18299","5":"Baden-Württemberg, Land","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_08"},{"1":"09","2":"2017","3":"GESAMT","4":"15638","5":"Bayern","6":"Einbürgerungsstatistik","7":"12511","8":"BEV008","9":"Einbürgerungen von Ausländern","10":"Kontinente (einschl. staatenlos etc.)","11":"Gesamt","12":"Naturalizations of Foreigners","13":"Continents (Including Stateless Etc.)","14":"Total","15":"2017_09"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- ### How to use `dg_call` ```r *dg_call(nuts_nr = 1, # NUTS-1 * year = 2017, # Specify Year * stat_name = "BEV008", # Stats on New Citizens * substat_name = "STAKNW") %>% # By Continent filter(STAKNW != "GESAMT") %>% group_by(param_description_en) %>% summarise(value = sum(value)) %>% mutate(param_description_en = ifelse(str_detect(param_description_en, "Stateless"), "Stateless", param_description_en)) %>% mutate(param_description_en = fct_reorder(param_description_en, value)) %>% ggplot(aes(param_description_en, value)) + geom_col(fill = "darkblue", alpha = .75) + geom_label(aes(label = value)) + theme_minimal() + labs(x = "", y = "Number of New Citizens\n", title = "New German Citizens by Origin Continent (2017)", caption = "Source: Einbürgerungsstatistik") + scale_y_continuous(labels = scales::comma, limits = c(0, 70000)) ``` --- ### How to use `dg_call` <img src="index_files/figure-html/unnamed-chunk-22-1.png" width="600" height="500" style="display: block; margin: auto;" /> --- ### How to use `dg_map` ```r *dg_map(nuts_nr = 1, * year = 2017, * stat_name = "AI0506") + ggthemes::theme_map() + ggplot2::scale_fill_viridis_c("Voter Turnout") + ggplot2::ggtitle("Voter Turnout in German Parliamentary Election (2017)") + ggplot2::theme(legend.position = "right") ``` --- ### How to use `dg_map` <img src="index_files/figure-html/unnamed-chunk-24-1.png" style="display: block; margin: auto;" /> --- class: center, middle ## More Maps! ![](https://media1.giphy.com/media/D3OdaKTGlpTBC/giphy.gif) --- class: center ![](images/dedomains.gif) --- class: center <img src="images/sustainableheat_map.png" width="450" height="600" style="display: block; margin: auto;" /> --- ## Hackathon Instructions + Material + You can fork/download this [GitHub repository](https://github.com/favstats/dg_hackathon_berlinR), which includes the slides and some example code. + You can also use *Rstudio Cloud*. We set up a "workspace" with all necessary packages pre-installed. Here is the [invite link](https://rstudio.cloud/spaces/49837/join?access_code=VCjFndcJdRrG7M1DP2VAq45LWZtan4xzHjhpUu xQ). + If you are looking for use cases of `datenguideR` check out the folder `/scripts`. In the end, you can present your dashboards, shiny apps, plots or analyses. The best submissions will be shared on Twitter (if they want to of course!:) **Important:** If you encounter any bugs, please use our issue tracker on [GitHub](https://github.com/CorrelAid/datenguideR/issues). --- ## Some Examples and Challenges .sixty[ <table class='gmisc_table' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' > <thead> <tr> <th style='border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>stat_name</th> <th style='border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>description_en</th> <th style='border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>challenge</th> </tr> </thead> <tbody> <tr> <td style='text-align: center;'>AENW01</td> <td style='text-align: center;'>Disposed / Treated Amount of Waste A.d. Own BL</td> <td style='text-align: center;'>Environmental Protection / Sustainability</td> </tr> <tr> <td style='text-align: center;'>AI1901</td> <td style='text-align: center;'>Household Waste per Inhabitant</td> <td style='text-align: center;'>Environmental Protection / Sustainability</td> </tr> <tr> <td style='text-align: center;'>AI_Z04</td> <td style='text-align: center;'>Share of Persons with MHG in the Total Population</td> <td style='text-align: center;'>Migration</td> </tr> <tr> <td style='text-align: center;'>AI0801</td> <td style='text-align: center;'>Unemployment Rate</td> <td style='text-align: center;'>Unemployment</td> </tr> <tr> <td style='text-align: center;'>AI2102</td> <td style='text-align: center;'>SGB II Quota Up to 64 Years</td> <td style='text-align: center;'>Unemployment</td> </tr> <tr> <td style='text-align: center;'>ERW009</td> <td style='text-align: center;'>Unemployment Rate on all Acquisition Persons.</td> <td style='text-align: center;'>Unemployment</td> </tr> <tr> <td style='text-align: center;'>AI0506</td> <td style='text-align: center;'>Voter Turnout, Federal Election</td> <td style='text-align: center;'>Politics</td> </tr> <tr> <td style='text-align: center;'>AI0606</td> <td style='text-align: center;'>Voter Turnout, European Elections</td> <td style='text-align: center;'>Politics</td> </tr> <tr> <td style='text-align: center;'>WAHL09</td> <td style='text-align: center;'>Valid Second Votes</td> <td style='text-align: center;'>Politics</td> </tr> <tr> <td style='text-align: center;'>WAHLSR</td> <td style='text-align: center;'>Voter Turnout</td> <td style='text-align: center;'>Politics</td> </tr> <tr> <td style='text-align: center;'>AI1302</td> <td style='text-align: center;'>Road Traffic Accidents per 10,000 Inhabitants</td> <td style='text-align: center;'>Traffic</td> </tr> <tr> <td style='text-align: center;'>AI1304</td> <td style='text-align: center;'>Fatalities in Road Traffic Accidents per 100,000 Inhabitants</td> <td style='text-align: center;'>Traffic</td> </tr> <tr> <td style='text-align: center;'>AI1601</td> <td style='text-align: center;'>Disposable Income per Inhabitant</td> <td style='text-align: center;'>Social Inequality</td> </tr> <tr> <td style='text-align: center;'>AI1703</td> <td style='text-align: center;'>GDP per Inhabitant</td> <td style='text-align: center;'>Social Inequality</td> </tr> <tr> <td style='text-align: center;'>FLC001</td> <td style='text-align: center;'>Living Space in Residential Buildings</td> <td style='text-align: center;'>Housing</td> </tr> <tr> <td style='text-align: center;'>BAU009</td> <td style='text-align: center;'>Residential Building</td> <td style='text-align: center;'>Housing</td> </tr> <tr> <td style='border-bottom: 2px solid grey; text-align: center;'>WOHNGB</td> <td style='border-bottom: 2px solid grey; text-align: center;'>Residential Building</td> <td style='border-bottom: 2px solid grey; text-align: center;'>Housing</td> </tr> </tbody> </table> ] --- class: center, middle, inverse ### Submissions from Previous hackathon ![](https://raw.githubusercontent.com/TripLLL/weRnuts3/master/trash_emoji.gif) Click [here](https://github.com/TripLLL/weRnuts3) for GitHub repository --- class: center, middle, inverse ### It's time to type some R code ![](https://media1.tenor.com/images/72bf7922ac0b07b2f7f8f630e4ae01d2/tenor.gif?itemid=11364811) #### Let's get to the ### `H A C K I N G` --- class: center, middle, inverse ### Thank you for listening ![](https://media1.tenor.com/images/da0f7d5d93faa11dfc36db1e6c6fdf2a/tenor.gif?itemid=6159389)