Description Usage Arguments Details Value Examples
View source: R/coin_aggregate.R
Takes indicator data and a specified structure and hierarchically aggregates according to the structure
specified in IndMeta
. Uses a variety of aggregation methods as specified by agtype
, which can be different for
each level of aggregation (see agtype_by_level
).
1 2 3 4 5 6 7 8 9 10 |
COIN |
COIN object |
agtype |
The type of aggregation method. One of either:
|
agweights |
The weights to use in the aggregation. This can either be:
|
dset |
Which data set (contained in COIN object) to use |
agtype_bylevel |
A character vector with aggregation types for each level. Note that if this is specified, |
agfunc |
A custom function to use for aggregation if |
avail_limit |
A data availability threshold, below which aggregation returns NA. This parameter is the fraction of data
availability needed in a given aggregation group to return an aggregated score. Specified as either |
out2 |
Where to output the results. If |
This function aggregates indicators according to the index structure specified in IndMeta
. It will either use a single
aggregation method for all aggregation levels (by specifying agtype
) or can use a different aggregation method for each
level of the index (see agtype_by_level
). Aggregation methods are typically weighted (e.g. weighted means), and the weights
for the aggregation are specified using the agweights
argument.
By default, this function will aggregate wherever possible - generally this means that if at least one value is available
for a given unit inside an aggregation group, it will return an aggregated score. Optionally, you can also specify a data
availability threshold which will instead return NA
if the data availability (within group and for each unit) falls below
the threshold. For example, you may have four indicators inside a group, and you might want to only produce an aggregated
score if data availability is at least 50% - this would be specified by avail_limit = 0.5
. It is also possible to specify
different data availability thresholds for different levels of the index, by specifying avail_limit
as a vector which has
one value for every aggregation level (the first value gives the threshold for the first aggregation, and so on up to the
final level).
An updated COIN containing the new aggregated data set at .$Data$Aggregated
.
1 2 3 4 5 6 7 8 | # assemble a COIN first
ASEM <- assemble(IndData = ASEMIndData, IndMeta = ASEMIndMeta, AggMeta = ASEMAggMeta)
# normalise the data
ASEM <- normalise(ASEM, dset = "Raw")
# aggregate the data
ASEM <- COINr::aggregate(ASEM, agtype="arith_mean", dset = "Normalised")
# check aggregated data set exists
stopifnot(!is.null(ASEM$Data$Aggregated))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.