Learn R Programming

rearrr (version 0.3.4)

rearranger_: Wrapper for running rearranging methods

Description

Wrapper for running rearranging methods

Usage

rearranger_(
  data,
  rearrange_fn,
  check_fn,
  cols = NULL,
  allowed_types = c("numeric", "factor", "character"),
  col = deprecated(),
  overwrite = FALSE,
  origin_fn = NULL,
  ...
)

Value

The sorted data.frame (tibble) / vector. Optionally with (a) sorting factor(s) added.

When `data` is a vector and no extra factors are returned by `rearrange_fn`, the output will be a vector. Otherwise, a data.frame.

Arguments

data

data.frame or vector.

rearrange_fn

Rearrange function to apply.

check_fn

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

cols

Column(s) to create sorting factor by. When `NULL` and `data` is a data.frame, the row numbers are used.

allowed_types

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

col

Column to create sorting factor by. When `NULL` and `data` is a data.frame, the row numbers are used.

overwrite

Whether to allow overwriting of existing columns. (Logical)

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 `rearrange_fn`.