Skip to contents

Applies [eiod_relative_band()] to several indicators in one call and returns a data frame of results, one column per indicator.

Usage

eiod_relative_all(data, group, map, midpoint = FALSE, prefix = "band_")

Arguments

data

A data frame with one row per respondent-day.

group

Integer vector of demographic groups 1-8, of length `nrow(data)`.

map

Named character vector: names are indicator keys, values are column names in `data`.

midpoint

If `TRUE`, return band midpoint percentiles rather than band numbers. See [eiod_relative_band()] for why a mean band is not a mean impact.

prefix

Prefix for the returned column names. Default `"band_"`.

Value

A data frame with `nrow(data)` rows and one integer column per indicator in `map`.

The map is the point

`map` states, explicitly, which column of your data holds which indicator. The **name** is the indicator key reiod knows (`"ghg"`); the **value** is whatever your column is actually called (`"ghg_kgco2e"`). They are different things, and nothing in reiod has ever required them to match - the vector API means `eiod_absolute_threshold(d$anything, grp, "ghg")` works.

Supply any subset. Indicators you do not name are simply absent from the result; there is no need to have all seven.

See also

[eiod_relative_band()], [eiod_absolute_all()]

Examples

data(eiod_demo)
grp <- eiod_age_sex_group(eiod_demo$age, eiod_demo$sex)

bands <- eiod_relative_all(eiod_demo, grp, eiod_demo_map)
sapply(bands, function(b) round(mean(b, na.rm = TRUE), 2))
#>   band_landtotal  band_landarable band_landpasture         band_ghg 
#>             4.68             3.00             5.10             3.81 
#>     band_eutroph       band_water      band_biodiv 
#>             4.85             3.39             5.06