Replaces specific values in a column based on a provided mapping file. Supports renaming across nested data structures and preserves factor levels.
Examples
# Load Data:
input_path <- system.file("extdata/in", package = "GTAPViz")
har.plot.data <- readRDS(file.path(input_path, "har.plot.data.rds"))
# Rename variables in a dataset
mapping_welfare <- data.frame(
ColumnName = "COLUMN",
OldName = c("alloc_A1", "ENDWB1", "tech_C1", "pop_D1", "pref_G1", "tot_E1", "IS_F1"),
NewName = c("Alloc Eff.", "Endwb", "Tech Chg.", "Pop", "Perf", "ToT", "I-S"),
stringsAsFactors = FALSE
)
har.plot.data <- rename_value(har.plot.data, mapping.file = mapping_welfare)