Denominate.coin {COINr} | R Documentation |
Denominate data set in a coin
Description
"Denominates" or "scales" indicators by other variables. Typically this is done by dividing extensive variables such as GDP by a scaling variable such as population, to give an intensive variable (GDP per capita).
Usage
## S3 method for class 'coin'
Denominate(
x,
dset,
denoms = NULL,
denomby = NULL,
denoms_ID = NULL,
f_denom = NULL,
write_to = NULL,
out2 = "coin",
...
)
Arguments
x |
A coin class object |
dset |
The name of the data set to apply the function to, which should be accessible in |
denoms |
An optional data frame of denominator data. Columns should be denominator data, with column names corresponding
to entries in |
denomby |
Optional data frame which specifies which denominators to use for each indicator, and any scaling factors
to apply. Should have columns |
denoms_ID |
An ID column for matching |
f_denom |
A function which takes two numeric vector arguments and is used to perform the denomination for each
column. By default, this is division, i.e. |
write_to |
If specified, writes the aggregated data to |
out2 |
Either |
... |
arguments passed to or from other methods |
Details
This function denominates a data set dset
inside the coin. By default, denominating variables are taken from
the coin, specifically as variables in iData
with Type = "Denominator"
in iMeta
(input to new_coin()
).
Specifications to map denominators to indicators are also taken by default from iMeta$Denominator
, if it exists.
These specifications can be overridden using the denoms
and denomby
arguments. The operator for denomination
can also be changed using the f_denom
argument.
See also documentation for Denominate.data.frame()
which is called by this method.
Value
An updated coin if out2 = "coin"
, else a data frame of denominated data if out2 = "df"
.
Examples
# build example coin
coin <- build_example_coin(up_to = "new_coin", quietly = TRUE)
# denominate (here, we only need to say which dset to use, takes
# specs and denominators from within the coin)
coin <- Denominate(coin, dset = "Raw")