{"id":23288046,"url":"https://github.com/e-kotov/mapineqr","last_synced_at":"2025-04-06T16:25:44.837Z","repository":{"id":268373571,"uuid":"901847267","full_name":"e-kotov/mapineqr","owner":"e-kotov","description":"Access Mapineq inequality indicators via API","archived":false,"fork":false,"pushed_at":"2025-02-23T19:40:44.000Z","size":4440,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T20:30:50.281Z","etag":null,"topics":["data","demogrpahy","r","rstats","socio-economic-indicators"],"latest_commit_sha":null,"homepage":"http://www.ekotov.pro/mapineqr/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/e-kotov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json"}},"created_at":"2024-12-11T12:31:57.000Z","updated_at":"2025-02-01T22:33:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"99a5f7b8-369a-42b4-8311-b35559dbeab7","html_url":"https://github.com/e-kotov/mapineqr","commit_stats":null,"previous_names":["e-kotov/mapineqr"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2Fmapineqr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2Fmapineqr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2Fmapineqr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2Fmapineqr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-kotov","download_url":"https://codeload.github.com/e-kotov/mapineqr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247511147,"owners_count":20950612,"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","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":["data","demogrpahy","r","rstats","socio-economic-indicators"],"created_at":"2024-12-20T03:13:38.235Z","updated_at":"2025-04-06T16:25:44.821Z","avatar_url":"https://github.com/e-kotov.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mapineqr\n\n\n\u003c!-- README.md is generated from README.qmd. Please edit that file --\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![Lifecycle:\nexperimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![R-CMD-check](https://github.com/e-kotov/mapineqr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/e-kotov/mapineqr/actions/workflows/R-CMD-check.yaml)\n[![CRAN\nstatus](https://www.r-pkg.org/badges/version/mapineqr.png)](https://CRAN.R-project.org/package=mapineqr)\n\u003c!-- badges: end --\u003e\n\nThe goal of `{mapineqr}` is to access the data from the [Mapineq.org\nAPI](https://www.mapineq.org/data-users/) and\n[dashboard](https://dashboard.mapineq.org/datacatalogue) (product of the\n[Mapineq](https://mapineq.eu/) project).\n\nFor Python package/module, see \u003chttps://github.com/e-kotov/mapineqpy\u003e.\n\n## Installation\n\n\u003c!-- Install from CRAN:\n\u0026#10;```r\ninstall.packages('mapineqr')\n``` --\u003e\n\nInstall latest release from **R-multiverse**:\n\n``` r\ninstall.packages('mapineqr',\n repos = c('https://e-kotov.r-universe.dev', 'https://cloud.r-project.org')\n)\n```\n\nYou can also install the development version of `mapineqr` from GitHub:\n\n``` r\nif (!require(\"pak\")) install.packages(\"pak\")\npak::pak(\"e-kotov/mapineqr\")\n```\n\n``` r\n# load packages used in the examples on this page\nlibrary(mapineqr)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(eurostat)\nlibrary(sf)\nlibrary(biscale)\n```\n\n## Basic Example - univariate data and maps\n\n1.  Get the full list of available data at NUTS 3 level:\n\n``` r\nlibrary(mapineqr)\n\navailable_data \u003c- mi_sources(level = \"3\")\nhead(available_data)\n```\n\n    # A tibble: 52 × 3\n       source_name    short_description      description                                                         \n       \u003cchr\u003e          \u003cchr\u003e                  \u003cchr\u003e                                                               \n     1 DEMO_R_D3AREA  \"Area by NUTS 3 regio\" Area by NUTS 3 region (ESTAT)                                       \n     2 PROJ_19RAASFR3 \"Assumptions for fert\" Assumptions for fertility rates by age, type of projection and NUTS…\n     3 PROJ_19RAASMR3 \"Assumptions for prob\" Assumptions for probability of dying by age, sex, type of projectio…\n     4 BD_HGNACE2_R3  \"Business demography \" Business demography and high growth enterprise by NACE Rev. 2 and N…\n     5 BD_SIZE_R3     \"Business demography \" Business demography by size class and NUTS 3 regions (ESTAT)        \n     6 CENS_11DWOB_R3 \"Conventional dwellin\" Conventional dwellings by occupancy status, type of building and NU…\n     7 CRIM_GEN_REG   \"Crimes recorded by t\" Crimes recorded by the police by NUTS 3 regions (ESTAT)             \n     8 DEMO_R_MAGEC3  \"Deaths by age group,\" Deaths by age group, sex and NUTS 3 region (ESTAT)                  \n     9 DEMO_R_MWK3_T  \"Deaths by week and N\" Deaths by week and NUTS 3 region (ESTAT)                            \n    10 DEMO_R_MWK3_TS \"Deaths by week, sex \" Deaths by week, sex and NUTS 3 region (ESTAT)                       \n    # ℹ 42 more rows\n    # ℹ Use `print(n = ...)` to see more rows\n\n2.  Select data source by `source_name` column and check it’s year and\n    NUTS level coverage:\n\n``` r\nmi_source_coverage(\"CRIM_GEN_REG\")\n```\n\n    # A tibble: 10 × 5\n       nuts_level year  source_name  short_description    description                                            \n       \u003cchr\u003e      \u003cchr\u003e \u003cchr\u003e        \u003cchr\u003e                \u003cchr\u003e                                                  \n     1 0          2008  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     2 0          2009  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     3 0          2010  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     4 1          2008  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     5 1          2009  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     6 1          2010  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     7 2          2008  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     8 2          2009  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n     9 2          2010  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n    10 3          2008  CRIM_GEN_REG Crimes recorded by t Crimes recorded by the police by NUTS 3 regions (ESTAT)\n\n3.  Check the available filters for the data source:\n\n``` r\nmi_source_filters(\"CRIM_GEN_REG\", year = 2010, level = \"2\")\n```\n\n    # A tibble: 6 × 4\n      field field_label                                                           label                                    value     \n      \u003cchr\u003e \u003cchr\u003e                                                                 \u003cchr\u003e                                    \u003cchr\u003e     \n    1 unit  Unit of measure                                                       Number                                   NR        \n    2 freq  Time frequency                                                        Annual                                   A         \n    3 iccs  International classification of crime for statistical purposes (ICCS) Intentional homicide                     ICCS0101  \n    4 iccs  International classification of crime for statistical purposes (ICCS) Robbery                                  ICCS0401  \n    5 iccs  International classification of crime for statistical purposes (ICCS) Burglary of private residential premises ICCS05012 \n    6 iccs  International classification of crime for statistical purposes (ICCS) Theft of a motorized land vehicle        ICCS050211\n\n4.  Choose the indicator to filter (let it be burglaries) to and get the\n    data:\n\n``` r\nx \u003c- mi_data(x_source = \"CRIM_GEN_REG\", year = 2010, level = \"2\", x_filters = list(iccs = \"ICCS05012\"))\nhead(x)\n```\n\n    # A tibble: 6 × 4\n      best_year geo   geo_name             x\n      \u003cchr\u003e     \u003cchr\u003e \u003cchr\u003e            \u003cint\u003e\n    1 2008      AT11  Burgenland (A)     223\n    2 2008      AT12  Niederösterreich  2557\n    3 2008      AT13  Wien              9319\n    4 2008      AT21  Kärnten            507\n    5 2008      AT22  Steiermark        1163\n    6 2008      AT31  Oberösterreich     988\n\n5.  Map the indicator using NUTS2 polygons:\n\n``` r\nlibrary(eurostat)\nlibrary(ggplot2)\n\n# load NUTS2 level polygons\nnuts2 \u003c- eurostat::get_eurostat_geospatial(nuts_level = 2, year = \"2010\", crs = \"4326\")\n\n# join data to NUTS2 polygons\nnuts2_crime \u003c- nuts2 |\u003e \n  left_join(x, by = \"geo\")\n\n# plot a map of burglaries\nmap_burglaries \u003c- ggplot(nuts2_crime) +\n  geom_sf(aes(fill = x)) +\n  scale_fill_viridis_c() +\n  labs(title = \"Number of burglaries of private residential premises in 2010\") +\n  theme_minimal()\n\nggsave(\"man/figures/map_burglaries.png\", map_burglaries, width = 8, height = 6, dpi = 200, create.dir = TRUE)\n```\n\n![Number of burglaries of private residential premises in\n2010](man/figures/map_burglaries.png)\n\n## Advanced Example - bivariate data and maps\n\n1.  Select two indicators.\n\nLet those be (1) unemployment rate:\n\n``` r\nmi_source_coverage(\"TGS00010\") |\u003e dplyr::arrange(desc(year))\n```\n\n    # A tibble: 12 × 5\n       nuts_level year  source_name short_description    description                                \n       \u003cchr\u003e      \u003cchr\u003e \u003cchr\u003e       \u003cchr\u003e                \u003cchr\u003e                                      \n     1 2          2022  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     2 2          2021  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     3 2          2020  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     4 2          2019  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     5 2          2018  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     6 2          2017  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     7 2          2016  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     8 2          2015  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n     9 2          2014  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n    10 2          2013  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n    11 2          2012  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n    12 2          2011  TGS00010    Unemployment rate by Unemployment rate by NUTS 2 regions (ESTAT)\n\nAnd (2) life expectancy:\n\n``` r\nmi_source_coverage(\"DEMO_R_MLIFEXP\") |\u003e dplyr::arrange(desc(year))\n```\n\n    # A tibble: 96 × 5\n       nuts_level year  source_name    short_description    description                                          \n       \u003cchr\u003e      \u003cchr\u003e \u003cchr\u003e          \u003cchr\u003e                \u003cchr\u003e                                                \n     1 0          2021  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     2 1          2021  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     3 2          2021  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     4 0          2020  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     5 1          2020  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     6 2          2020  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     7 0          2019  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     8 1          2019  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n     9 2          2019  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n    10 0          2018  DEMO_R_MLIFEXP Life expectancy by a Life expectancy by age, sex and NUTS 2 region (ESTAT)\n    # ℹ 86 more rows\n    # ℹ Use `print(n = ...)` to see more rows\n\n2.  Check for available filters:\n\n``` r\nmi_source_filters(\"TGS00010\", year = 2018, level = \"2\")\n```\n\n    # A tibble: 12 × 4\n       field   field_label                                                     label                                                                      value \n       \u003cchr\u003e   \u003cchr\u003e                                                           \u003cchr\u003e                                                                      \u003cchr\u003e \n     1 unit    Unit of measure                                                 Percentage                                                                 PC    \n     2 isced11 International Standard Classification of Education (ISCED 2011) All ISCED 2011 levels                                                      TOTAL \n     3 isced11 International Standard Classification of Education (ISCED 2011) Less than primary, primary and lower secondary education (levels 0-2)      ED0-2 \n     4 isced11 International Standard Classification of Education (ISCED 2011) Upper secondary and post-secondary non-tertiary education (levels 3 and 4) ED3_4 \n     5 isced11 International Standard Classification of Education (ISCED 2011) Tertiary education (levels 5-8)                                            ED5-8 \n     6 isced11 International Standard Classification of Education (ISCED 2011) Unknown                                                                    UNK   \n     7 isced11 International Standard Classification of Education (ISCED 2011) No response                                                                NRP   \n     8 sex     Sex                                                             Total                                                                      T     \n     9 sex     Sex                                                             Males                                                                      M     \n    10 sex     Sex                                                             Females                                                                    F     \n    11 freq    Time frequency                                                  Annual                                                                     A     \n    12 age     Age class                                                       15 years or over                                                           Y_GE15\n\n``` r\nmi_source_filters(\"DEMO_R_MLIFEXP\", year = 2018, level = \"2\") |\u003e print(n=90)\n```\n\n    # A tibble: 91 × 4\n       field field_label     label            value\n       \u003cchr\u003e \u003cchr\u003e           \u003cchr\u003e            \u003cchr\u003e\n     1 unit  Unit of measure Year             YR   \n     2 sex   Sex             Total            T    \n     3 sex   Sex             Males            M    \n     4 sex   Sex             Females          F    \n     5 freq  Time frequency  Annual           A    \n     6 age   Age class       Less than 1 year Y_LT1\n     7 age   Age class       1 year           Y1   \n     8 age   Age class       2 years          Y2   \n     9 age   Age class       3 years          Y3   \n    10 age   Age class       4 years          Y4   \n    11 age   Age class       5 years          Y5   \n    12 age   Age class       6 years          Y6   \n    13 age   Age class       7 years          Y7   \n    14 age   Age class       8 years          Y8   \n    15 age   Age class       9 years          Y9   \n    16 age   Age class       10 years         Y10  \n    17 age   Age class       11 years         Y11  \n    ...\n\n3.  Get the data for the two indicators:\n\n``` r\nxy_data \u003c- mi_data(\n  year = 2018,\n  level = \"2\",\n  x_source = \"TGS00010\", x_filters = list(isced11 = \"TOTAL\", unit = \"PC\", age = \"Y_GE15\", sex = \"T\", freq = \"A\"),\n  y_source = \"DEMO_R_MLIFEXP\", y_filters = list(unit = \"YR\", age = \"Y_LT1\", sex = \"T\", freq = \"A\")\n)\n```\n\n4.  Plot the scratterplot:\n\n``` r\nedu_v_life_exp_plot \u003c- ggplot(xy_data, aes(x = x, y = y)) +\n  geom_point() +\n  labs(x = \"Percentage of all adults aged 15 years or over with a degree\", y = \"Life expectancy at birth\") +\n  theme_minimal()\n# ggsave(\"man/figures/edu_v_life_exp_plot.png\", edu_v_life_exp_plot, width = 8, height = 6, units = \"in\", dpi = 300)\n```\n\n![Education vs Life Expectancy](man/figures/edu_v_life_exp_plot.png)\n\n4.  Add the bivariate data to the NUTS2 polygons and create a plot:\n\n``` r\nnuts2 \u003c- eurostat::get_eurostat_geospatial(nuts_level = 2, year = \"2016\", crs = \"4326\")\nnuts2_edu_v_life_exp \u003c- nuts2 |\u003e\n  left_join(xy_data, by = \"geo\")\n```\n\n``` r\nlibrary(biscale)\nbidata \u003c- bi_class(nuts2_edu_v_life_exp, x = x, y = y, style = \"quantile\", dim = 3)\n\nlegend \u003c- bi_legend(pal = \"GrPink\",\n                    dim = 3,\n                    xlab = \"              Higher % with a degree\",\n                    ylab = \"              Higher life expectancy\",\n                    size = 8)\n```\n\n``` r\nmap \u003c- ggplot() +\n  geom_sf(data = bidata, mapping = aes(fill = bi_class), color = \"white\", size = 0.1, show.legend = FALSE) +\n  bi_scale_fill(pal = \"GrPink\", dim = 3) +\n  labs(\n    title = \"Education vs Life Expectancy\"\n  ) +\n  bi_theme()\n\npng(\"man/figures/edu_v_life_exp_map.png\", width = 8, height = 6, units = \"in\", res = 300)\nprint(map)\nprint(legend, vp = grid::viewport(x = 0.4, y = .75, width = 0.2, height = 0.2, angle = -45))\ndev.off()\n```\n\n![Education vs Life Expectancy](man/figures/edu_v_life_exp_map.png)\n\n## Citation\n\nTo cite the R package and data in publications use:\n\nKotov E (2024). *mapineqr. Access Mapineq inequality indicators via\nAPI*. doi:10.32614/CRAN.package.mapineqr\n\u003chttps://doi.org/10.32614/CRAN.package.mapineqr\u003e,\n\u003chttps://github.com/e-kotov/mapineqr\u003e.\n\nMills M, Leasure D (2024). “Mapineq Link: Geospatial Dashboard and\nDatabase.” doi:10.5281/zenodo.13864000\n\u003chttps://doi.org/10.5281/zenodo.13864000\u003e.\n\nBibTeX:\n\n    @Manual{mapineqr,\n      title = {mapineqr. Access Mapineq inequality indicators via API},\n      author = {Egor Kotov},\n      year = {2024},\n      url = {https://github.com/e-kotov/mapineqr},\n      doi = {10.32614/CRAN.package.mapineqr},\n    }\n\n    @Misc{mapineq_link,\n      title = {Mapineq Link: Geospatial Dashboard and Database},\n      author = {Melinda C Mills and Douglas Leasure},\n      year = {2024},\n      month = {October},\n      publisher = {Mapineq deliverables. Turku: INVEST Research Flagship Centre / University of Turku},\n      doi = {10.5281/zenodo.13864000},\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-kotov%2Fmapineqr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-kotov%2Fmapineqr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-kotov%2Fmapineqr/lists"}