Adjust numeric column values in a data frame using mathematical transformations
Source:R/plot_mods.R
adjust_column_values.RdApplies a named mathematical transformation to a specified numeric column in a data frame,
adding the transformed values as a new column (original column name + ".adj").
The transformation name must be one of the allowed functions listed in safe_resolve_adj_fxn
(e.g., "log2", "log10", "sqrt", "abs", "as.factor"). The original data frame is returned unchanged
if no transformation is specified or if the supplied name is invalid.
Usage
adjust_column_values(
df,
x.col = NULL,
y.col = NULL,
color.col = NULL,
x.adj.fun = NULL,
y.adj.fun = NULL,
color.adj.fun = NULL
)Arguments
- df
A data frame containing the column to be transformed.
- x.col
Character scalar. Name of the column for x‑axis values (optional).
- y.col
Character scalar. Name of the column for y‑axis values (optional).
- color.col
Character scalar. Name of the column for color values (optional).
- x.adj.fun
Character scalar. Name of a transformation function to apply to x‑axis values, as accepted by
safe_resolve_adj_fxn(e.g., "log2", "log10", "sqrt"). IfNULLor an empty string, x‑axis values are left unchanged.- y.adj.fun
Character scalar. Name of a transformation function to apply to y‑axis values, as accepted by
safe_resolve_adj_fxn. IfNULLor an empty string, y‑axis values are left unchanged.- color.adj.fun
Character scalar. Name of a transformation function to apply to color values, as accepted by
safe_resolve_adj_fxn. IfNULLor an empty string, color values are left unchanged.