standardizeTree: Standardize Tree

Description Usage Arguments Value

View source: R/standardizeTree.R

Description

This function takes an input dataset and commodity tree and standardizes the data according to the tree.

Usage

1
2
standardizeTree(data, tree, elements, standParams, zeroWeight = c(),
  sugarHack = TRUE)

Arguments

data

A data.table object containing the data of interest.

tree

The commodity tree, specified as a data.table object. The columns should be childVar (the commodity code of the child), parentVar (the commodity code of the parent), extractionVar (numeric value specifying the extraction rate), and shareVar (numeric value specifying how the commodity should be split up). There are also two optional columns: targetVar (either "T", "B" or "F" indicating if that commodity is a target commodity, should be backward standardized, or should be forward standardized) and standDev (containing the standard deviation estimates which should be aggregated as well). If the target is missing, everything is assumed to be backward standardized. If no standDev is provided, a deviation of 0 is assumed. The actual names of the columns are specified in standParams.

elements

The element codes for nodes that should be standardized. These correspond to the different "elements" of the FBS, such as production, imports, exports, etc.

standParams

The parameters for standardization. These parameters provide information about the columns of data and tree, specifying (for example) which columns should be standardized, which columns represent parents/children, etc.

zeroWeight

Vector. Vector containg the items that must have a zero weights because they represent co-byproducts. (see the example wheat, wheat flour, wheat germ..)

sugarHack

Logical. Indicates if the commodity tree should be edited by this program to give the correction standardization of sugar? This is a hack and should be fixed, but for now it is generally necessary.

Value

A data.table with the commodities standardized to the highest level in the tree.

If an element is not a child in the tree, then "standardize" it to itself with a rate of 1 and a share of 1.


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