Skip to contents

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

Usage

eiod_absolute_all(data, group, map, prefix = "abs_")

Arguments

data

A data frame with one row per respondent-day.

group

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

map

Named character vector: names are indicator keys, values are column names in `data`. See [eiod_demo_map] for the shape.

prefix

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

Value

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

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_absolute_threshold()] for the single-indicator form and the full discussion of the metric; [eiod_relative_all()].

Examples

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

# your own column names, stated once
res <- eiod_absolute_all(eiod_demo, grp,
                         map = c(ghg = "ghg_kgco2e", biodiv = "biodiv_pdf"))
colMeans(res, na.rm = TRUE)
#>    abs_ghg abs_biodiv 
#>  0.2216667  0.5714286 

# all seven, using the mapping shipped with the demo data
all7 <- eiod_absolute_all(eiod_demo, grp, eiod_demo_map)
round(100 * colMeans(all7, na.rm = TRUE), 1)
#>   abs_landtotal  abs_landarable abs_landpasture         abs_ghg     abs_eutroph 
#>            70.2            80.8            68.7            22.2            53.5 
#>       abs_water      abs_biodiv 
#>            95.2            57.1