get_transform_names: Return labels for given transforms

View source: R/statistical_simulation.r

get_transform_namesR 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 trans (see function trans_new in package scales)

prefer_primitive

If "never", the function always returns the value of the field name (except if this is missing). If "always", the name of the called function is returned unless it cannot be identified (in many cases, the transform will not be primitive). If "if_shorter", the shorter option of the two above is returned if both can be retrieved.

Details

The label of a transform could be the value of the field name from each object of class trans, 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 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)))

WoodSimulatR documentation built on June 20, 2022, 9:05 a.m.