getIn: Get subsets of indicator data

Description Usage Arguments Details Value Examples

View source: R/getIn.R

Description

This function does a number of things that are useful for many COINr functions and operations. First, it checks to see what kind of input object is input. Then, it selects the indicator data according to the specs supplied.

Usage

1
2
3
4
5
6
7
8
9
getIn(
  obj,
  dset = "Raw",
  icodes = NULL,
  aglev = NULL,
  usel = NULL,
  use_group = NULL,
  justnumeric = TRUE
)

Arguments

obj

An input object. The function can handle either the COIN object, or a data frame. The data frame should have each column as an indicator, and optional columns UnitCode and UnitName which specify the code (or name) of each unit. Any columns except these latter two will be treated as indicators. Any other type of object will return an error.

dset

If input is a COIN object, this specifies which data set in .$Data to use.

icodes

An optional character vector of indicator codes to subset the indicator data. Usefully, can also refer to an aggregation group name, and data will be subsetted accordingly. NOTE does not work with multiple aggregate group names.

aglev

The aggregation level to take indicator data from. Integer from 1 (indicator level) to N (top aggregation level, typically the index).

usel

An optional unit code, or character vector of unit codes to use to filter the data. The returned data will only include rows corresponding to the usel, unless usel = NULL (default).

use_group

An optional grouping variable and group to filter data from. Of the format list(Group_Var = Group), where Group_Var is a Group_ column that must be present in the selected data set, and Group is a specified group inside that grouping variable. This filters the selected data to only include rows from the specified group. Alternatively, this argument can work in conjunction with usel: if usel is specified, use_group may be input as a string simply representing a group column. In that case the data will be filtered to include only rows from the group(s) which the usel belong to. If usel is specified and use_group is specified as a list, usel will take precedence and use_group will be ignored.

justnumeric

Logical: if TRUE, removes any non-numeric columns from ind_data_only. Otherwise keeps all except those.

Details

For example, specifying dset = "Raw" and icodes = c("Ind1", "Ind5"), it will return the indicator columns named "Ind1" and "Ind5" (if they exist), in the format described below. icodes can be indicators or aggregation groups, and can call multiple groups.

You can also specify which aggregation level to target, using the aglev argument. See examples below, and in particular the COINr online documentation.

As well as selection of columns, you can also filter to specific rows using unit codes as a reference, and/or grouping variables. This is done using the usel and use_group arguments. This gives the ability to isolate a unit inside a given group, for example.

getIn() is used by many COINr functions for plotting, accessing and reporting subsets of indicator data.

Value

A list with the following entries:

Examples

1
2
3
4
5
6
7
8
# assemble ASEM COIN
ASEM <- assemble(IndData = ASEMIndData, IndMeta = ASEMIndMeta, AggMeta = ASEMAggMeta)
# get indicator data from Social pillar
SocData <- getIn(ASEM, dset = "Raw", icodes = "Social", aglev = 1)
# Indicator codes
SocData$IndCodes
# Indicator data (no other columns)
SocData$ind_data_only

COINr documentation built on Nov. 30, 2021, 9:06 a.m.