Adds descriptions and unit information to GTAP data based on a specified mapping mode. Supports external mappings or default GTAPv7 mappings, allowing users to enrich datasets with standardized metadata.
Usage
add_mapping_info(
data_list,
external_map = NULL,
mapping = "GTAPv7",
description_info = TRUE,
unit_info = TRUE
)
Arguments
- data_list
A data structure containing GTAP variables.
- external_map
Optional data frame with mapping information (must include "Variable", "Description", and "Unit" columns).
- mapping
Character. Mapping mode: - `"GTAPv7"` (default): Uses standard GTAPv7 definitions. - `"Yes"`: Uses only the supplied descriptions and units from `external_map`. - `"No"`: Does not add any descriptions or units. - `"Mix"`: Prioritizes `external_map`, but falls back to GTAPv7 for missing values.
- description_info
Logical. If `TRUE`, adds description information to the data.
- unit_info
Logical. If `TRUE`, adds unit information to the data.
Examples
# Load Sample Data:
sl4_data1 <- HARplus::load_sl4x(system.file("extdata/in", "EXP1.sl4",
package = "GTAPViz"))
# Get Data by Variable Name
sl4_data1 <- HARplus::get_data_by_var(c("qgdp", "EV"), sl4_data1)
# Add mapping using GTAPv7 defaults
gtap_data <- add_mapping_info(sl4_data1, mapping = "GTAPv7")
# Use an external mapping file
my_mapping <- data.frame(Variable = c("qgdp", "EV"),
Description = c("Real GDP", "Welfare"),
Unit = c("percent", "millionUSD")) # <- Fixed closing quote
gtap_data <- add_mapping_info(sl4_data1, external_map = my_mapping,
mapping = "Mix")