robust_scale: Robust Scaling of Numeric and Categorical Variables
Description
Applies robust scaling to numeric and categorical variables. For numeric variables,
the function centers by the median and scales by the MAD. For categorical variables
with 2–4 unique levels, it applies a custom transformation to map them to numeric values.
Usage
robust_scale(x, group)
Value
A scaled numeric vector or a data frame with scaled columns.
Arguments
x
A numeric vector, factor, matrix, or data frame. If a matrix or data frame is provided, scaling is applied
column-wise.
group
vector indicating which group is the TG to scale to
Details
This function is designed to make numeric and categorical variables comparable.
This is an internal function that should not be used by package users.