get_transform_names {WoodSimulatR} | R Documentation |
Return labels for given transforms
Description
The function simbase_covar
allows the specification of a
transform for one or more variables. The present function creates short
names for such transforms for use in labelling (by default, the labelling is
done by simbase_labeler
).
Usage
get_transform_names(
transforms,
prefer_primitive = c("if_shorter", "never", "always")
)
Arguments
transforms |
A named list of objects of class |
prefer_primitive |
If "never", the function always returns the value of
the field |
Details
The label of a transform could be the value of the field name
from
each object of class trans
(or transform
),
but also the name of the transform
function itself, if it is a primitive function or just calls one function.
Each object of class trans
(or transform
)
should have a field name
which can be returned by the present function.
The function examines the field transform
.
If this field contains a primitive function (see is_primitive
),
or if there is just one function call in the body of this transform
function, we can also return the name of this called function.
If there is no field name
and no single function is called from the
function defined in the field transform
,
a generic function name "f."
is returned.
Value
A named vector of transforms names.
Examples
get_transform_names(list(a = scales::log_trans(), b = scales::boxcox_trans(0)));
get_transform_names(list(x = list(name = 'a very long name', transform = log, inverse = exp)))