Calculate median/MAD-based M-scores for selected numeric variables and return both the transformed data and the parameters needed to review or reuse the transformation.
Usage
CreateMScoreObject(
df,
variables = NULL,
names_prefix = "M_",
RetainLabels = TRUE,
RenameLabels = TRUE,
center = TRUE,
scale = TRUE,
constant = 1.4826
)Arguments
- df
A data frame.
- variables
Character vector of numeric variables to transform. If
NULL, numeric variables are detected withgetNumVars().- names_prefix
Prefix for generated M-score columns.
- RetainLabels
Logical; keep variable labels when possible.
- RenameLabels
Logical; rename generated labels when labels are retained.
- center
Logical; subtract the median before scaling.
- scale
Logical; divide by the median absolute deviation.
- constant
Scaling constant passed to
stats::mad().
