View source: R/data_manipulation_export.R
rename_dims | R Documentation |
Renames dimension and list names in structured SL4 or HAR objects.
rename_dims(data_obj, mapping_df, rename_list_names = FALSE)
data_obj |
A structured SL4 or HAR object. |
mapping_df |
A two-column data frame where the first column ( |
rename_list_names |
Logical. If |
Replaces old dimension names with new ones as specified in mapping_df
.
If rename_list_names = TRUE
, renames list element names as well.
Ensures consistency across SL4 and HAR datasets.
The modified SL4 or HAR object with updated dimension names and, optionally, updated list names.
Pattawee Puangchit
get_data_by_var
, get_data_by_dims
# Import sample data:
sl4_data <- load_sl4x(system.file("extdata", "TAR10.sl4", package = "HARplus"))
# Define a renaming map
mapping_df <- data.frame(
old = c("REG", "COMM"),
new = c("Region", "Commodity")
)
# Rename columns in the dataset
rename_dims(sl4_data, mapping_df)
# Rename both columns and list names
rename_dims(sl4_data, mapping_df, rename_list_names = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.