rename_dims: Rename Dimensions in SL4 or HAR Objects

View source: R/data_manipulation_export.R

rename_dimsR Documentation

Rename Dimensions in SL4 or HAR Objects

Description

Renames dimension and list names in structured SL4 or HAR objects.

Usage

rename_dims(data_obj, mapping_df, rename_list_names = FALSE)

Arguments

data_obj

A structured SL4 or HAR object.

mapping_df

A two-column data frame where the first column (old) contains the current names, and the second column (new) contains the new names.

rename_list_names

Logical. If TRUE, renames list element names. Default is FALSE.

Details

  • 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.

Value

The modified SL4 or HAR object with updated dimension names and, optionally, updated list names.

Author(s)

Pattawee Puangchit

See Also

get_data_by_var, get_data_by_dims

Examples

# 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)


HARplus documentation built on April 4, 2025, 4:14 a.m.