pivot_data {HARplus} | R Documentation |
Pivot Data from SL4 or HAR Objects
Description
Transforms long-format SL4 or HAR data into wide format by pivoting selected columns. Supports both single data frames and nested lists.
Usage
pivot_data(data_obj, pivot_cols, name_repair = "unique")
Arguments
data_obj |
A list or data frame. The SL4 or HAR data to pivot. |
pivot_cols |
Character vector. Column names to use as pivot keys. |
name_repair |
Character. Method for handling duplicate column names ( |
Details
Uses
tidyr::pivot_wider()
internally to reshape data.Allows multiple columns to be pivoted simultaneously.
Recursively processes nested lists, ensuring all data frames are transformed.
Value
A transformed data object where the specified pivot_cols
are pivoted into wide format.
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"))
# Extract multiple variables
data_multiple <- get_data_by_var(c("qo", "qxs"), sl4_data)
# Pivot a single column
pivoted_data <- pivot_data(data_multiple, pivot_cols = "REG")
# Pivot multiple columns
pivoted_data_multi <- pivot_data(data_multiple, pivot_cols = c("REG", "COMM"))
[Package HARplus version 1.0.1 Index]