Package 'mapineqr'

Title: Access Mapineq Inequality Indicators via API
Description: Access Mapineq inequality indicators via API.
Authors: Egor Kotov [aut, cre]
Maintainer: Egor Kotov <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-12-20 13:27:05 UTC
Source: https://github.com/e-kotov/mapineqr

Help Index


Get univariate or bivariate data for a specific source

Description

Fetches univariate or bivariate data for a given source, year, NUTS level, and selected filters.

Usage

mi_data(
  x_source,
  y_source = NULL,
  year,
  level,
  x_filters = list(),
  y_filters = NULL,
  limit = 2000
)

Arguments

x_source

A character string specifying the source name for the x variable.

y_source

(Optional) A character string specifying the source name for the y variable.

year

A character or integer specifying the year.

level

A character string specifying the NUTS level ("0", "1", "2", or "3").

x_filters

A ⁠named list⁠ where the names are the filter fields for the x variable and the values are the selected values for those fields. Default is an empty list. To find out which filters to use, use mi_source_filters with the desired source_name.

y_filters

(Optional) A ⁠named list⁠ where the names are the filter fields for the y variable and the values are the selected values for those fields. Default is NULL. To find out which filters to use, use mi_source_filters with the desired source_name.

limit

An integer specifying the maximum number of results to return. Default is 2000.

Value

A tibble with the following columns:

For univariate data (when y_source is not provided):

  • best_year: the best available year, closest to the requested year.

  • geo: code for the NUTS region at the requested level.

  • geo_name: name of the NUTS region at the requested level.

  • x: the value of the univariate variable.

For bivariate data (when y_source is provided):

  • best_year: the best available year, closest to the requested year (same for both x and y variables).

  • geo: code for the NUTS region at the requested level.

  • geo_name: name of the NUTS region at the requested level.

  • x: the value of the x variable.

  • y: the value of the y variable.

Examples

# Univariate example
mi_data(
  x_source = "TGS00010",
  year = 2020,
  level = "2",
  x_filters = list(isced11 = "TOTAL", unit = "PC", age = "Y_GE15", freq = "A")
)

# Bivariate example
mi_data(
  x_source = "TGS00010",
  y_source = "DEMO_R_MLIFEXP",
  year = 2020,
  level = "2",
  x_filters = list(isced11 = "TOTAL", unit = "PC", age = "Y_GE15", freq = "A"),
  y_filters = list(unit = "YR", age = "Y_LT1", freq = "A")
)

Get a list of available NUTS levels

Description

Get a list of available NUTS levels

Usage

mi_nuts_levels()

Value

a character vector of valid NUTS levels that will be accepted by other functions.

Examples

mi_nuts_levels()

Get NUTS level and Year coverage for a specific source

Description

Get the NUTS level and Year coverage for a specific data source.

Usage

mi_source_coverage(source_name, limit = 1500)

Arguments

source_name

name of the data source

limit

An integer specifying the maximum number of results to return. Default is 2000.

Value

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

Examples

mi_source_coverage("BD_HGNACE2_R3")

mi_source_coverage("ghs_smod")

Get column values for filtering a source

Description

Fetches the possible filtering values for a given source, year, and NUTS level.

Usage

mi_source_filters(source_name, year, level, filters = list(), limit = 40)

Arguments

source_name

A character string specifying the source name (f_resource).

year

A character or integer specifying the year.

level

A character string specifying the NUTS level ("0", "1", "2", or "3").

filters

A ⁠named list⁠ where the names are the filter fields and the values are the selected values for those fields. Default is an empty list.

limit

An integer specifying the maximum number of results to return. Default is 2000.

Value

A tibble with the fields, labels, and their possible values for filtering.

Examples

mi_source_filters(
  source_name = "DEMO_R_FIND2",
  year = 2020,
  level = "2",
  filters = list(unit = "YR")
)

Get a list of available data sources

Description

Get a list of available data sources

Usage

mi_sources(level, year = NULL, limit = 1000)

Arguments

level

a character string specifying the NUTS level ("0", "1", "2", or "3"). You can also always check valid NUTS levels using mi_nuts_levels.

year

an integer of length 1, specifying the year. Optional.

limit

An integer specifying the maximum number of results to return. Default is 2000.

Value

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

Examples

# 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)