From 4aec23292110529f866dc0d298a670590acdfd2a Mon Sep 17 00:00:00 2001 From: Egor Kotov Date: Sun, 15 Dec 2024 17:57:31 +0100 Subject: [PATCH] initial version with only sources endpoints supported --- .Rbuildignore | 9 ++ CITATION.cff | 152 +++++++++++++++++++++ DESCRIPTION | 21 +++ LICENSE | 23 +--- LICENSE.md | 21 +++ NAMESPACE | 6 + R/levels.R | 27 ++++ R/onLoad.R | 12 ++ R/sources.R | 155 ++++++++++++++++++++++ README.md | 54 +++++++- README.qmd | 65 +++++++++ codemeta.json | 167 ++++++++++++++++++++++++ cran-comments.md | 5 + inst/CITATION | 27 ++++ inst/schemaorg.json | 38 ++++++ man/mi_nuts_levels.Rd | 20 +++ man/mi_source_coverage.Rd | 31 +++++ man/mi_sources.Rd | 38 ++++++ mapineqr.Rproj | 17 +++ tests/testthat.R | 12 ++ tools/meta-data-update-and-submission.R | 15 +++ 21 files changed, 893 insertions(+), 22 deletions(-) create mode 100644 .Rbuildignore create mode 100644 CITATION.cff create mode 100644 DESCRIPTION create mode 100644 LICENSE.md create mode 100644 NAMESPACE create mode 100644 R/levels.R create mode 100644 R/onLoad.R create mode 100644 R/sources.R create mode 100644 README.qmd create mode 100644 codemeta.json create mode 100644 cran-comments.md create mode 100644 inst/CITATION create mode 100644 inst/schemaorg.json create mode 100644 man/mi_nuts_levels.Rd create mode 100644 man/mi_source_coverage.Rd create mode 100644 man/mi_sources.Rd create mode 100644 mapineqr.Rproj create mode 100644 tests/testthat.R create mode 100644 tools/meta-data-update-and-submission.R diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..3b5abcf --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,9 @@ +^mapineqr\.Rproj$ +^\.Rproj\.user$ +^LICENSE\.md$ +^README\.qmd$ +^cran-comments\.md$ +^private$ +^tools$ +^CITATION\.cff$ +^codemeta\.json$ diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..c888de1 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,152 @@ +# -------------------------------------------- +# CITATION file created with {cffr} R package +# See also: https://docs.ropensci.org/cffr/ +# -------------------------------------------- + +cff-version: 1.2.0 +message: 'To cite package "mapineqr" in publications use:' +type: software +license: MIT +title: 'mapineqr: Access Mapineq inequality indicators via API' +version: 0.0.0.9000 +doi: 10.32614/CRAN.package.mapineqr +abstract: Access Mapineq inequality indicators via API. +authors: +- family-names: Kotov + given-names: Egor + email: kotov.egor@gmail.com + orcid: https://orcid.org/0000-0001-6690-5345 +preferred-citation: + type: manual + title: mapineqr. Access Mapineq inequality indicators via API + authors: + - family-names: Kotov + given-names: Egor + email: kotov.egor@gmail.com + orcid: https://orcid.org/0000-0001-6690-5345 + year: '2024' + url: https://github.com/e-kotov/mapineqr + doi: 10.32614/CRAN.package.mapineqr +contact: +- family-names: Kotov + given-names: Egor + email: kotov.egor@gmail.com + orcid: https://orcid.org/0000-0001-6690-5345 +references: +- type: generic + title: 'Mapineq Link: Geospatial Dashboard and Database' + authors: + - family-names: Mills + given-names: Melinda C + - family-names: Leasure + given-names: Douglas + year: '2024' + month: '10' + publisher: + name: 'Mapineq deliverables. Turku: INVEST Research Flagship Centre / University + of Turku' + doi: 10.5281/zenodo.13864000 +- type: software + title: checkmate + abstract: 'checkmate: Fast and Versatile Argument Checks' + notes: Imports + url: https://mllg.github.io/checkmate/ + repository: https://CRAN.R-project.org/package=checkmate + authors: + - family-names: Lang + given-names: Michel + email: michellang@gmail.com + orcid: https://orcid.org/0000-0001-9754-0393 + year: '2024' +- type: software + title: dplyr + abstract: 'dplyr: A Grammar of Data Manipulation' + notes: Imports + url: https://dplyr.tidyverse.org + repository: https://CRAN.R-project.org/package=dplyr + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + orcid: https://orcid.org/0000-0003-4757-117X + - family-names: François + given-names: Romain + orcid: https://orcid.org/0000-0002-2444-4226 + - family-names: Henry + given-names: Lionel + - family-names: Müller + given-names: Kirill + orcid: https://orcid.org/0000-0002-1416-3412 + - family-names: Vaughan + given-names: Davis + email: davis@posit.co + orcid: https://orcid.org/0000-0003-4777-038X + year: '2024' +- type: software + title: httr2 + abstract: 'httr2: Perform HTTP Requests and Process the Responses' + notes: Imports + url: https://httr2.r-lib.org + repository: https://CRAN.R-project.org/package=httr2 + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2024' +- type: software + title: purrr + abstract: 'purrr: Functional Programming Tools' + notes: Imports + url: https://purrr.tidyverse.org/ + repository: https://CRAN.R-project.org/package=purrr + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@rstudio.com + orcid: https://orcid.org/0000-0003-4757-117X + - family-names: Henry + given-names: Lionel + email: lionel@rstudio.com + year: '2024' +- type: software + title: rlang + abstract: 'rlang: Functions for Base Types and Core R and ''Tidyverse'' Features' + notes: Imports + url: https://rlang.r-lib.org + repository: https://CRAN.R-project.org/package=rlang + authors: + - family-names: Henry + given-names: Lionel + email: lionel@posit.co + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2024' +- type: software + title: tibble + abstract: 'tibble: Simple Data Frames' + notes: Imports + url: https://tibble.tidyverse.org/ + repository: https://CRAN.R-project.org/package=tibble + authors: + - family-names: Müller + given-names: Kirill + email: kirill@cynkra.com + orcid: https://orcid.org/0000-0002-1416-3412 + - family-names: Wickham + given-names: Hadley + email: hadley@rstudio.com + year: '2024' +- type: software + title: testthat + abstract: 'testthat: Unit Testing for R' + notes: Suggests + url: https://testthat.r-lib.org + repository: https://CRAN.R-project.org/package=testthat + authors: + - family-names: Wickham + given-names: Hadley + email: hadley@posit.co + year: '2024' + version: '>= 3.0.0' + diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..de15132 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,21 @@ +Package: mapineqr +Title: Access Mapineq inequality indicators via API +Version: 0.0.0.9000 +Authors@R: + person("Egor", "Kotov", , "kotov.egor@gmail.com", role = c("aut", "cre"), + comment = c(ORCID = "0000-0001-6690-5345")) +Description: Access Mapineq inequality indicators via API. +License: MIT + file LICENSE +Imports: + checkmate, + dplyr, + httr2, + purrr, + rlang, + tibble +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.2 diff --git a/LICENSE b/LICENSE index 4f234fc..7504d09 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,2 @@ -MIT License - -Copyright (c) 2024 Egor Kotov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +YEAR: 2024 +COPYRIGHT HOLDER: mapineqr authors diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..69900f2 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2024 mapineqr authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..297d339 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,6 @@ +# Generated by roxygen2: do not edit by hand + +export(mi_nuts_levels) +export(mi_source_coverage) +export(mi_sources) +importFrom(rlang,.data) diff --git a/R/levels.R b/R/levels.R new file mode 100644 index 0000000..c03ff59 --- /dev/null +++ b/R/levels.R @@ -0,0 +1,27 @@ +#' Get a list of available NUTS levels +#' +#' @return a `character` vector of valid NUTS levels that will be accepted by other functions. +#' +#' @export +#' +#' @examples +#' \dontrun{ +#' mi_nuts_levels() +#' } +#' +mi_nuts_levels <- function(){ + base_api_endpoint <- getOption("mapineqr.base_api_endpoint") + url_endpoint <- paste0(base_api_endpoint, + "get_levels/items.json") + + response <- httr2::request(url_endpoint) |> + httr2::req_headers( + "Content-Type" = "application/json", + "User-Agent" = getOption("mapineqr.user_agent") + ) |> + httr2::req_method("GET") |> + httr2::req_perform() + + response_data <- httr2::resp_body_json(response) |> unlist() + return(response_data) +} diff --git a/R/onLoad.R b/R/onLoad.R new file mode 100644 index 0000000..f268e0b --- /dev/null +++ b/R/onLoad.R @@ -0,0 +1,12 @@ +.onLoad <- function(libname, pkgname) { + op <- options() + op.mapineqr <- list( + mapineqr.api_spec_json = "https://mapineqfeatures.web.rug.nl/api.json", + mapineqr.base_api_endpoint = "https://mapineqfeatures.web.rug.nl/functions/postgisftw.", + mapineq.user_agent = "mapineqr R package" + ) + toset <- !(names(op.mapineqr) %in% names(op)) + if (any(toset)) options(op.mapineqr[toset]) + + invisible() +} diff --git a/R/sources.R b/R/sources.R new file mode 100644 index 0000000..3855121 --- /dev/null +++ b/R/sources.R @@ -0,0 +1,155 @@ +#' Get a list of available data sources +#' +#' @param level a `character` string specifying the NUTS level ("0", "1", "2", or "3"). You can also always check valid NUTS levels using \code{\link{mi_nuts_levels}}. +#' @param year an `integer` of length 1, specifying the year. Optional. +#' @param limit an `integer` of length 1 specifying the maximum number of sources to return. Defaults to 1000. +#' +#' @return a `tibble` of sources with the following columns: +#' +#' * `source_name`: name of the data source +#' * `short_description`: short description of the data source +#' * `description`: description of the data source +#' +#' @importFrom rlang .data +#' @export +#' +#' @examples +#' +#' \dontrun{ +#' # get up to 10 sources for NUTS level 3 +#' mi_sources("3", limit = 10) +#' +#' # get all sources for NUTS level 3 and year 2020 +#' mi_sources("3", year = 2020) +#' +#' } +#' +mi_sources <- function( + level, + year = NULL, + limit = 1000 +){ + + checkmate::assert_choice(level, c("0", "1", "2", "3")) + checkmate::assert_integerish(limit, lower = 1, max.len = 1) + checkmate::assert_integerish(year, null.ok = TRUE, max.len = 1) + + base_api_endpoint <- getOption("mapineqr.base_api_endpoint") + + # select which API endpoint to use depending on whether year is provided + if( is.null(year) ){ + url_endpoint <- paste0(base_api_endpoint, + "get_source_by_nuts_level/items.json") + } else if (!is.null(year)) { + url_endpoint <- paste0(base_api_endpoint, + "get_source_by_year_nuts_level/items.json") + } + + # prepare query parameters + query_params <- list( + `_level` = level, + `limit` = limit + ) + if (!is.null(year)) { + query_params$`_year` <- year + } + + response <- httr2::request(url_endpoint) |> + httr2::req_headers( + "Content-Type" = "application/json", + "User-Agent" = getOption("mapineqr.user_agent") + ) |> + httr2::req_url_query(!!!query_params) |> + httr2::req_method("GET") |> + httr2::req_perform() + + response_data <- httr2::resp_body_json(response, simplifyVector = TRUE) |> + tibble::as_tibble() |> + dplyr::rename( + description = .data$f_description, + source_name = .data$f_resource, + short_description = .data$f_short_description + ) |> + dplyr::select( + .data$source_name, + .data$short_description, + .data$description + ) + + return(response_data) +} + +#' Get NUTS level and Year coverage for a specific source +#' +#' Get the NUTS level and Year coverage for a specific data source. +#' +#' @param source_name name of the data source +#' +#' @return a `tibble` containing the following columns: +#' +#' * `nuts_level`: NUTS level +#' * `year`: year +#' * `source_name`: name of the data source (mathces the `source_name` requested by the user) +#' * `short_description`: short description of the data source +#' * `description`: description of the data source +#' +#' @importFrom rlang .data +#' @export +#' +#' @examples +#' \dontrun{ +#' mi_source_coverage("BD_HGNACE2_R3") +#' +#' mi_source_coverage("ghs_smod") +#' } +mi_source_coverage <- function( + source_name +){ + checkmate::assert_string(source_name) + + # get full source metadata list + all_sources <- mi_nuts_levels() |> + purrr::map(~ mi_sources(level = .x)) |> + dplyr::bind_rows() |> + unique() + + # filter to the specific source + source_metadata <- all_sources |> + dplyr::filter(.data$source_name == !!source_name) + + # fail if no source found + if(nrow(source_metadata) == 0){ + message("Invalid `source_name`, please find valid source names using mi_sources()") + return(invisible(NULL)) + } + + base_api_endpoint <- getOption("mapineqr.base_api_endpoint") + url_endpoint <- paste0(base_api_endpoint, + "get_year_nuts_level_from_source/items.json") + + response <- httr2::request(url_endpoint) |> + httr2::req_headers( + "Content-Type" = "application/json", + "User-Agent" = getOption("mapineqr.user_agent") + ) |> + httr2::req_url_query( + `_resource` = source_name + ) |> + httr2::req_method("GET") |> + httr2::req_perform() + + response_data <- httr2::resp_body_json(response, simplifyVector = TRUE) |> + tibble::as_tibble() |> + dplyr::rename(nuts_level = .data$f_level, year = .data$f_year) |> + dplyr::mutate(source_name = source_name) |> + dplyr::left_join(source_metadata, by = "source_name") |> + dplyr::select( + .data$nuts_level, + .data$year, + .data$source_name, + .data$short_description, + .data$description + ) + + return(response_data) +} diff --git a/README.md b/README.md index 6d0f200..39b2ca5 100644 --- a/README.md +++ b/README.md @@ -1 +1,53 @@ -# mapineqr \ No newline at end of file +# mapineqr + + + + +An R package to access the data from the API +and dashboard (product of the [Mapineq](https://mapineq.eu/) proejct) + +# mapineqr + + + +[![Lifecycle: +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![CRAN +status](https://www.r-pkg.org/badges/version/mapineqr.png)](https://CRAN.R-project.org/package=mapineqr) + + +The goal of mapineqr is to … + +## Installation + +You can install the development version of mapineqr from +[GitHub](https://github.com/) with: + +``` r +# install.packages("pak") +pak::pak("e-kotov/mapineqr") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +``` r +library(mapineqr) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? +You can include R chunks like so: + +``` r +summary(cars) +``` + +You’ll still need to render `README.Rmd` regularly, to keep `README.md` +up-to-date. `devtools::build_readme()` is handy for this. + +You can also embed plots, for example: + +In that case, don’t forget to commit and push the resulting figure +files, so they display on GitHub and CRAN. diff --git a/README.qmd b/README.qmd new file mode 100644 index 0000000..a058d1a --- /dev/null +++ b/README.qmd @@ -0,0 +1,65 @@ +--- +title: mapineqr +format: gfm +execute: + message: false + warning: false +eval: false +--- + + + +An R package to access the data from the [https://www.mapineq.org/](https://www.mapineq.org/) API and dashboard (product of the [Mapineq](https://mapineq.eu/) proejct) + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# mapineqr + + +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![CRAN status](https://www.r-pkg.org/badges/version/mapineqr)](https://CRAN.R-project.org/package=mapineqr) + + +The goal of mapineqr is to ... + +## Installation + +You can install the development version of mapineqr from [GitHub](https://github.com/) with: + +``` r +# install.packages("pak") +pak::pak("e-kotov/mapineqr") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +```{r example} +library(mapineqr) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: + +```{r cars} +summary(cars) +``` + +You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. + +You can also embed plots, for example: + +```{r pressure, echo = FALSE} +plot(pressure) +``` + +In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. diff --git a/codemeta.json b/codemeta.json new file mode 100644 index 0000000..bf015da --- /dev/null +++ b/codemeta.json @@ -0,0 +1,167 @@ +{ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "@type": "SoftwareSourceCode", + "identifier": "mapineqr", + "description": "Access Mapineq inequality indicators via API.", + "name": "mapineqr: Access Mapineq inequality indicators via API", + "license": "https://spdx.org/licenses/MIT", + "version": "0.0.0.9000", + "programmingLanguage": { + "@type": "ComputerLanguage", + "name": "R", + "url": "https://r-project.org" + }, + "runtimePlatform": "R version 4.4.2 (2024-10-31)", + "author": [ + { + "@type": "Person", + "givenName": "Egor", + "familyName": "Kotov", + "email": "kotov.egor@gmail.com", + "@id": "https://orcid.org/0000-0001-6690-5345" + } + ], + "maintainer": [ + { + "@type": "Person", + "givenName": "Egor", + "familyName": "Kotov", + "email": "kotov.egor@gmail.com", + "@id": "https://orcid.org/0000-0001-6690-5345" + } + ], + "softwareSuggestions": [ + { + "@type": "SoftwareApplication", + "identifier": "testthat", + "name": "testthat", + "version": ">= 3.0.0", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=testthat" + } + ], + "softwareRequirements": { + "1": { + "@type": "SoftwareApplication", + "identifier": "checkmate", + "name": "checkmate", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=checkmate" + }, + "2": { + "@type": "SoftwareApplication", + "identifier": "dplyr", + "name": "dplyr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=dplyr" + }, + "3": { + "@type": "SoftwareApplication", + "identifier": "httr2", + "name": "httr2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=httr2" + }, + "4": { + "@type": "SoftwareApplication", + "identifier": "purrr", + "name": "purrr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=purrr" + }, + "5": { + "@type": "SoftwareApplication", + "identifier": "rlang", + "name": "rlang", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rlang" + }, + "6": { + "@type": "SoftwareApplication", + "identifier": "tibble", + "name": "tibble", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=tibble" + }, + "SystemRequirements": null + }, + "fileSize": "11.224KB", + "citation": [ + { + "@type": "SoftwareSourceCode", + "datePublished": "2024", + "author": [ + { + "@type": "Person", + "givenName": "Egor", + "familyName": "Kotov", + "email": "kotov.egor@gmail.com", + "@id": "https://orcid.org/0000-0001-6690-5345" + } + ], + "name": "mapineqr. Access Mapineq inequality indicators via API", + "identifier": "10.32614/CRAN.package.mapineqr", + "url": "https://github.com/e-kotov/mapineqr", + "@id": "https://doi.org/10.32614/CRAN.package.mapineqr", + "sameAs": "https://doi.org/10.32614/CRAN.package.mapineqr" + }, + { + "@type": "CreativeWork", + "datePublished": "2024", + "author": [ + { + "@type": "Person", + "givenName": "Melinda C", + "familyName": "Mills" + }, + { + "@type": "Person", + "givenName": "Douglas", + "familyName": "Leasure" + } + ], + "name": "Mapineq Link: Geospatial Dashboard and Database", + "identifier": "10.5281/zenodo.13864000", + "@id": "https://doi.org/10.5281/zenodo.13864000", + "sameAs": "https://doi.org/10.5281/zenodo.13864000" + } + ], + "codeRepository": "https://github.com/e-kotov/mapineqr", + "readme": "https://github.com/e-kotov/mapineqr/blob/main/README.md", + "developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html#experimental" +} diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/inst/CITATION b/inst/CITATION new file mode 100644 index 0000000..daa6184 --- /dev/null +++ b/inst/CITATION @@ -0,0 +1,27 @@ +citHeader("To cite the R package and data in publications use:") + +bibentry( + key = "mapineqr", + bibtype = "Manual", + title = "mapineqr. Access Mapineq inequality indicators via API", + author = person("Egor", "Kotov", , "kotov.egor@gmail.com", + role = c("aut", "cre"), + comment = c(ORCID = "0000-0001-6690-5345")), + year = "2024", + url = "https://github.com/e-kotov/mapineqr", + doi = "10.32614/CRAN.package.mapineqr" +) + +bibentry( + key = "mapineq_link", + bibtype = "Misc", + title = "Mapineq Link: Geospatial Dashboard and Database", + author = c( + person("Melinda C", "Mills"), + person("Douglas", "Leasure") + ), + year = "2024", + month = "October", + publisher = "Mapineq deliverables. Turku: INVEST Research Flagship Centre / University of Turku", + doi = "10.5281/zenodo.13864000" +) diff --git a/inst/schemaorg.json b/inst/schemaorg.json new file mode 100644 index 0000000..9798381 --- /dev/null +++ b/inst/schemaorg.json @@ -0,0 +1,38 @@ +{ + "@context": "https://schema.org", + "@graph": [ + { + "type": "SoftwareSourceCode", + "author": { + "id": "https://orcid.org/0000-0001-6690-5345", + "type": "Person", + "email": "kotov.egor@gmail.com", + "familyName": "Kotov", + "givenName": "Egor" + }, + "codeRepository": "https://github.com/e-kotov/mapineqr", + "description": "Access Mapineq inequality indicators via API.", + "license": "https://spdx.org/licenses/MIT", + "name": "mapineqr: Access Mapineq inequality indicators via API", + "programmingLanguage": { + "type": "ComputerLanguage", + "name": "R", + "url": "https://r-project.org" + }, + "runtimePlatform": "R version 4.4.2 (2024-10-31)", + "version": "0.0.0.9000" + }, + { + "id": "https://doi.org/10.32614/CRAN.package.mapineqr", + "type": "SoftwareSourceCode", + "author": { + "id": "https://orcid.org/0000-0001-6690-5345", + "type": "Person", + "email": "kotov.egor@gmail.com", + "familyName": "Kotov", + "givenName": "Egor" + }, + "name": "mapineqr. Access Mapineq inequality indicators via API" + } + ] +} diff --git a/man/mi_nuts_levels.Rd b/man/mi_nuts_levels.Rd new file mode 100644 index 0000000..b162b47 --- /dev/null +++ b/man/mi_nuts_levels.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/levels.R +\name{mi_nuts_levels} +\alias{mi_nuts_levels} +\title{Get a list of available NUTS levels} +\usage{ +mi_nuts_levels() +} +\value{ +a \code{character} vector of valid NUTS levels that will be accepted by other functions. +} +\description{ +Get a list of available NUTS levels +} +\examples{ +\dontrun{ +mi_nuts_levels() +} + +} diff --git a/man/mi_source_coverage.Rd b/man/mi_source_coverage.Rd new file mode 100644 index 0000000..f15fe29 --- /dev/null +++ b/man/mi_source_coverage.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sources.R +\name{mi_source_coverage} +\alias{mi_source_coverage} +\title{Get NUTS level and Year coverage for a specific source} +\usage{ +mi_source_coverage(source_name) +} +\arguments{ +\item{source_name}{name of the data source} +} +\value{ +a \code{tibble} containing the following columns: +\itemize{ +\item \code{nuts_level}: NUTS level +\item \code{year}: year +\item \code{source_name}: name of the data source (mathces the \code{source_name} requested by the user) +\item \code{short_description}: short description of the data source +\item \code{description}: description of the data source +} +} +\description{ +Get the NUTS level and Year coverage for a specific data source. +} +\examples{ +\dontrun{ +mi_source_coverage("BD_HGNACE2_R3") + +mi_source_coverage("ghs_smod") +} +} diff --git a/man/mi_sources.Rd b/man/mi_sources.Rd new file mode 100644 index 0000000..d5ddbdb --- /dev/null +++ b/man/mi_sources.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sources.R +\name{mi_sources} +\alias{mi_sources} +\title{Get a list of available data sources} +\usage{ +mi_sources(level, year = NULL, limit = 1000) +} +\arguments{ +\item{level}{a \code{character} string specifying the NUTS level ("0", "1", "2", or "3"). You can also always check valid NUTS levels using \code{\link{mi_nuts_levels}}.} + +\item{year}{an \code{integer} of length 1, specifying the year. Optional.} + +\item{limit}{an \code{integer} of length 1 specifying the maximum number of sources to return. Defaults to 1000.} +} +\value{ +a \code{tibble} of sources with the following columns: +\itemize{ +\item \code{source_name}: name of the data source +\item \code{short_description}: short description of the data source +\item \code{description}: description of the data source +} +} +\description{ +Get a list of available data sources +} +\examples{ + +\dontrun{ +# get up to 10 sources for NUTS level 3 +mi_sources("3", limit = 10) + +# get all sources for NUTS level 3 and year 2020 +mi_sources("3", year = 2020) + +} + +} diff --git a/mapineqr.Rproj b/mapineqr.Rproj new file mode 100644 index 0000000..aaa62a5 --- /dev/null +++ b/mapineqr.Rproj @@ -0,0 +1,17 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +Encoding: UTF-8 + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..134da24 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(mapineqr) + +# test_check("mapineqr") diff --git a/tools/meta-data-update-and-submission.R b/tools/meta-data-update-and-submission.R new file mode 100644 index 0000000..75b8d92 --- /dev/null +++ b/tools/meta-data-update-and-submission.R @@ -0,0 +1,15 @@ +# before release +# usethis::use_version("patch") +# usethis::use_version("minor") +cffr::cff_write() +codemetar::write_codemeta(write_minimeta = T) +usethis::use_tidy_description() +# urlchecker::url_check() +# devtools::check(remote = TRUE, manual = TRUE) +# devtools::check_win_devel() +# revdepcheck::revdep_check(num_workers = 4) + +# devtools::submit_cran() + +# usethis::use_github_release() +# usethis::use_dev_version(push = TRUE)