View source: R/data_manipulation_export.R
pivot_data | R Documentation |
Transforms long-format SL4 or HAR data into wide format by pivoting selected columns. Supports both single data frames and nested lists.
pivot_data(data_obj, pivot_cols, name_repair = "unique")
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 ( |
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.
A transformed data object where the specified pivot_cols
are pivoted into wide format.
Pattawee Puangchit
get_data_by_var
, get_data_by_dims
# 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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.