mapCommodityTree: Map Commodity Tree

Description Usage Arguments Value

View source: R/mapCommodityTree.R

Description

This function maps the oldCommodityTree (under one commodity code system) into a new commodity tree. It does this by first translating all parents and children in the tree to their new elements. This may create duplicated edges, and in those cases the extraction rates and shares are averaged.

Usage

1
2
3
4
5
mapCommodityTree(oldCommodityTree, commodityMap, oldColname, newColname,
  parentColname = "measuredItemParentFS",
  childColname = "measuredItemChildFS",
  extractionColname = "extractionRate", shareColname = "share",
  byKey = NULL)

Arguments

oldCommodityTree

A data.table containing the edge structure of the commodity tree (specified by parent/child columns) and the extraction rates and shares. Typically, this is produced from getOldCommodityTree.

commodityMap

A data.table containing the mapping from the old commodity codes to the new commodity codes. Currently, no other information from this table will be utilized.

oldColname

The column name of commodityMap which contains the IDs for the old commodity codes.

newColname

The column name of commodityMap which contains the IDs for the new commodity codes.

parentColname

The column name of commodityTree which contains the ID for the parent commodity.

childColname

The column name of commodityTree which contains the ID for the child commodity.

extractionColname

The column name of commodityTree which contains the extraction rates. Extraction rates represent the quantity of the child that can be produced from 1 unit of the parent. Typically, though, they are expressed in 10,000's: i.e. if the extraction rate is 8000, 1 parent unit can be processed into 1 * 8000/10000 = 0.8 child units.

shareColname

The column name of commodityTree which contains the shares variable. This value represents the percent of the parent commodity that is processed into the child. For example, a share value of 50 means that 300 units of the parent would be processed into 300*50/100 = 150 units of the child.

byKey

Character vector of column names of oldCommodityTree which should be used in the by argument when averaging the final extraction rates. The new parent and child item codes will always be included, but the user may want to include year, country, etc. if the passed commodity tree has those dimensions.

Value

A data.table of the new commodity tree.


SWS-Methodology/faoswsStandardization documentation built on Feb. 7, 2022, 5:05 a.m.