Learn R Programming

rearrr (version 0.3.5)

multi_mutator_: Wrapper for running multi-column mutator methods

Description

Wrapper for running multi-column mutator methods

Usage

multi_mutator_(
  data,
  mutate_fn,
  check_fn,
  cols = NULL,
  suffix = "_mutated",
  overwrite = FALSE,
  force_df = TRUE,
  allowed_types = c("numeric", "factor"),
  allow_missing = FALSE,
  min_dims = 1,
  altered_col = NULL,
  keep_original = TRUE,
  origin_fn = NULL,
  ...
)

Value

The mutated data.frame (tibble).

Arguments

data

data.frame or vector.

mutate_fn

Mutator to apply.

check_fn

Function with checks post-preparation of `data` and `col(s)`. Should not return anything.

cols

Columns to mutate values of. Must be specified when `data` is a data.frame.

suffix

Suffix to add to the names of the generated columns.

Use an empty string (i.e. "") to overwrite the original columns.

overwrite

Whether to allow overwriting of existing columns. (Logical)

force_df

Whether to return a data.frame when `data` is a vector.

allowed_types

Allowed types of the `col(s)` columns. The type restrictions do not apply to columns not mentioned in the `col(s)` argument.

allow_missing

Whether to allow missing values (NAs). (Logical)

min_dims

Minimum number of dimensions (cols) after preparations. When `data` is a vector setting `min_dims` to 2 will use both the index and the values as columns.

altered_col

Additional column that is mutated but is not mentioned in `cols`.

keep_original

Whether to keep the original columns. (Logical)

Some columns may have been overwritten, in which case only the newest versions are returned.

origin_fn

Function for finding the origin coordinates.

Input: Each column will be passed as a vector in the order of `cols`.

Output: A vector with one scalar per dimension.

Can be created with create_origin_fn() if you want to apply the same function to each dimension.

E.g. `create_origin_fn(median)` would find the median of each column.

Built-in functions are centroid(), most_centered(), and midrange()

...

Named arguments for the `mutate_fn`.