get_str_weak {COINr} | R Documentation |
Generate strengths and weaknesses for a specified unit
Description
Generates a table of strengths and weaknesses for a selected unit, based on ranks, or ranks within a specified grouping variable.
Usage
get_str_weak(
coin,
dset,
usel = NULL,
topN = 5,
bottomN = 5,
withcodes = TRUE,
use_group = NULL,
unq_discard = NULL,
min_discard = TRUE,
report_level = NULL,
with_units = TRUE,
adjust_direction = NULL,
sig_figs = 3
)
Arguments
coin |
A coin |
dset |
The data set to extract indicator data from, to use as strengths and weaknesses. |
usel |
A selected unit code |
topN |
The top N indicators to report |
bottomN |
The bottom N indicators to report |
withcodes |
If |
use_group |
An optional grouping variable to use for reporting
in-group ranks. Specifying this will report the ranks of the selected unit within the group of |
unq_discard |
Optional parameter for handling discrete indicators. Some indicators may be binary
variables of the type "yes = 1", "no = 0". These may be picked up as strengths or weaknesses, when they
may not be wanted to be highlighted, since e.g. maybe half of units will have a zero or a one. This argument
takes a number between 0 and 1 specifying a unique value threshold for ignoring indicators as strengths. E.g.
setting |
min_discard |
If |
report_level |
Aggregation level to report parent codes from. For example, setting
|
with_units |
If |
adjust_direction |
If |
sig_figs |
Number of significant figures to round values to. If |
Details
This currently only works at the indicator level. Indicators with NA
values for the selected unit are ignored.
Strengths and weaknesses mean the topN
-ranked indicators for the selected unit. Effectively, this takes the rank that the
selected unit has in each indicator, sorts the ranks, and takes the top N highest and lowest.
This function must be used with a little care: indicators should be adjusted for their directions before use,
otherwise a weakness might be counted as a strength, and vice versa. Use the adjust_direction
parameter
to help here.
A further useful parameter is unq_discard
, which also filters out any indicators with a low number of
unique values, based on a specified threshold. Also min_discard
which filters out any indicators which
have the minimum rank.
The best way to use this function is to play around with the settings a little bit. The reason being that
in practice, indicators have very different distributions and these can sometimes lead to unexpected
outcomes. An example is if you have an indicator with 50% zero values, and the rest non-zero (but unique).
Using the sport ranking system, all units with zero values will receive a rank which is equal to the number
of units divided by two. This then might be counted as a "strength" for some units with overall low scores.
But a zero value can hardly be called a strength. This is where the min_discard
function can help out.
Problems such as these mainly arise when e.g. generating a large number of country profiles.
This function replaces the now-defunct getStrengthNWeak()
from COINr < v1.0.
Value
A list containing a data frame .$Strengths
, and a data frame .$Weaknesses
.
Each data frame has columns with indicator code, name, rank and value (for the selected unit).
Examples
# build example coin
coin <- build_example_coin(up_to = "new_coin", quietly = TRUE)
# get strengths and weaknesses for ESP
get_str_weak(coin, dset = "Raw", usel = "ESP")