getNutritiveFactors: Get Nutritive Factors

Description Usage Arguments Value

Description

This function pulls nutrient factor data from the SWS. The tricky part is that some nutrient factors are specific to country/year, and some apply to all years or all countries or both. Thus, we must combine these factors in a reasonable way and generate a useable table.

Usage

1
2
3
4
getNutritiveFactors(nutrientDomain = "agriculture",
  nutrientDataset = "aupus_ratio", geographicAreaM49 = NULL,
  measuredElement = NULL, measuredItemCPC = NULL, timePointYearsSP = NULL,
  flagVector = c("flagRatio"))

Arguments

nutrientDomain

A character specifig the SWS domain where the nutrient factor table is stores in. The default value points to the "agriculture" domain.

nutrientDataset

A character specifig the SWS dataset where the nutrient factor table is stores in. The default value points to the "aupus_ratio" domain.

geographicAreaM49

A character vector of area codes. "0" (wildcard) will always be included if it is not passed, but passing it does not cause any issues. If NULL, the function pulls all area codes from the dimension table.

measuredElement

A character vector of measuredElement codes. These are specific to the nutrient factors table (i.e. Aupus Ratios). Calories, proteins, and fats are 1001, 1003, and 1005, respectively. If NULL, the function pulls all area codes from the dimension table.

measuredItemCPC

A character vector of CPC codes for the commodities of interest. If NULL, the function pulls all area codes from the dimension table.

timePointYearsSP

A character vector of years. As with geographicAreaM49, "0" need not be passed but can be. If NULL, the function pulls all area codes from the dimension table.

flagVector

Vector of charactes identifing the colnames referring to the flag column/columns. This parameter has been added in order to allow the pull nutrient-data from diffent dataset characterised from different flag systems. For example the default option has been set in order to pull nutrient-data from the aupus-ratio dataset.

NOTE: This function chooses the nutrient factor for a particular country/year by first looking for data specific to that country/year, then data specific to that country and all years, then data specific to that year and all countries, then data for all years and all countries. This order may not be appropriate, but it was my best guess at the time of writing the code.

Value

A data.table containing the nutrient factors. Any nutrient factor that applies to multiple years/countries is now represented as multiple rows in the table.


SWS-Methodology/faoswsUtil documentation built on May 9, 2019, 11:53 a.m.