Skip to contents

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

# \donttest{
# Univariate example
mi_data(
  x_source = "TGS00010",
  year = 2020,
  level = "2",
  x_filters = list(isced11 = "TOTAL", unit = "PC", age = "Y_GE15", freq = "A")
)
#> # A tibble: 910 × 4
#>    best_year geo   geo_name             x
#>    <chr>     <chr> <chr>            <dbl>
#>  1 2021      AL01  Veri              NA  
#>  2 2021      AL02  Qender            NA  
#>  3 2021      AL03  Jug               NA  
#>  4 2021      AT11  Burgenland         4.2
#>  5 2021      AT11  Burgenland        NA  
#>  6 2021      AT11  Burgenland         4.2
#>  7 2021      AT12  Niederösterreich   4.2
#>  8 2021      AT12  Niederösterreich   4  
#>  9 2021      AT12  Niederösterreich   4.3
#> 10 2021      AT13  Wien              10.6
#> # ℹ 900 more rows

# 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")
)
#> # A tibble: 2,000 × 5
#>    best_year geo   geo_name       x     y
#>    <chr>     <chr> <chr>      <dbl> <dbl>
#>  1 2018      AL01  Veri        NA    75.1
#>  2 2018      AL01  Veri        NA    77.3
#>  3 2018      AL01  Veri        NA    79.5
#>  4 2018      AL02  Qender      NA    78.9
#>  5 2018      AL02  Qender      NA    81.5
#>  6 2018      AL02  Qender      NA    76.5
#>  7 2018      AL03  Jug         NA    76.2
#>  8 2018      AL03  Jug         NA    78.2
#>  9 2018      AL03  Jug         NA    74.3
#> 10 2018      AT11  Burgenland   4.2  79.8
#> # ℹ 1,990 more rows
# }