View source: R/data_manipulation.R
| add_mapping_info | R Documentation |
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.
Adds description and unit information to GTAP data structures based on a specified mapping mode. This function supports internal GTAPv7 mappings, external mappings, or a combination of both.
add_mapping_info(
data_list,
external_map = NULL,
mapping = "GTAPv7",
description_info = TRUE,
unit_info = TRUE
)
data_list |
A list or nested data structure containing GTAP output data frames. |
external_map |
Optional data frame. External mapping must include columns: |
mapping |
Character. Mapping mode for assigning metadata to variables. Options:
|
description_info |
Logical. If |
unit_info |
Logical. If |
The mapping argument supports:
The same data structure as input with added "Description" and "Unit" columns, if applicable.
Pattawee Puangchit
convert_units, rename_value
# Load GTAP SL4 data
input_path <- system.file("extdata/in", package = "GTAPViz")
sl4.plot.data <- readRDS(file.path(input_path, "sl4.plot.data.rds"))
# Add mapping using GTAPv7 defaults
gtap_data <- add_mapping_info(sl4.plot.data, mapping = "GTAPv7")
# Use a custom mapping file
my_map <- data.frame(
Variable = c("qgdp", "EV"),
Description = c("Real GDP", "Welfare"),
Unit = c("percent", "million USD")
)
gtap_data <- add_mapping_info(sl4.plot.data, external_map = my_map, mapping = "Mix")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.