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 = 2500
)
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
orinteger
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, usemi_source_filters
with the desiredsource_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 isNULL
. To find out which filters to use, usemi_source_filters
with the desiredsource_name
.- limit
An
integer
specifying the maximum number of results to return. Default is 2500. This default should be enough for most uses, as it is well above the number of NUTS 3 regions in the EU. The maximum limited by the API is 10000.
Value
A tibble
with the following columns:
geo
: code for the (NUTS) region at the requested level.geo_name
: name of the (NUTS) region at the requested level.geo_source
: source (type) of the spatial units at the requested level.geo_year
: year of the (NUTS) region at the requested level.x_year
: The year of the predictor variable (X), included in bivariate requests.y_year
(optional): The year of the outcome variable (Y), included in bivariate requests (only included wheny_source
is provided).x
: the value of the univariate variable.y
(optional): the value of the y variable (only included wheny_source
is provided).
Examples
# \donttest{
# Univariate example
mi_data(
x_source = "TGS00010",
year = 2020,
level = "2",
x_filters = list(isced11 = "TOTAL", sex = "F")
)
#> # A tibble: 334 × 6
#> geo geo_name geo_source geo_year x_year x
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 AL01 Veri NUTS 2021 2020 NA
#> 2 AL02 Qender NUTS 2021 2020 NA
#> 3 AL03 Jug NUTS 2021 2020 NA
#> 4 AT11 Burgenland NUTS 2021 2020 NA
#> 5 AT12 Niederösterreich NUTS 2021 2020 4
#> 6 AT13 Wien NUTS 2021 2020 10
#> 7 AT21 Kärnten NUTS 2021 2020 5
#> 8 AT22 Steiermark NUTS 2021 2020 4.4
#> 9 AT31 Oberösterreich NUTS 2021 2020 3.7
#> 10 AT32 Salzburg NUTS 2021 2020 3
#> # ℹ 324 more rows
# Bivariate example
mi_data(
x_source = "TGS00010",
y_source = "DEMO_R_MLIFEXP",
year = 2020,
level = "2",
x_filters = list(isced11 = "TOTAL", sex = "F"),
y_filters = list(age = "Y2", sex = "F")
)
#> # A tibble: 332 × 8
#> geo geo_name geo_source geo_year x_year y_year x y
#> <chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 AL01 Veri NUTS 2018 2020 2020 NA 78.3
#> 2 AL02 Qender NUTS 2018 2020 2020 NA 80.4
#> 3 AL03 Jug NUTS 2018 2020 2020 NA 76.9
#> 4 AT11 Burgenland NUTS 2018 2020 2020 NA 81.8
#> 5 AT12 Niederösterreich NUTS 2018 2020 2020 4 81.8
#> 6 AT13 Wien NUTS 2018 2020 2020 10 80.9
#> 7 AT21 Kärnten NUTS 2018 2020 2020 5 82.2
#> 8 AT22 Steiermark NUTS 2018 2020 2020 4.4 81.9
#> 9 AT31 Oberösterreich NUTS 2018 2020 2020 3.7 82.3
#> 10 AT32 Salzburg NUTS 2018 2020 2020 3 82.7
#> # ℹ 322 more rows
# }