Wrapper for running closest to / furthest from rearrange methods
by_distance_rearranger_(
data,
cols,
origin = NULL,
origin_fn = NULL,
shuffle_ties = FALSE,
decreasing = FALSE,
origin_col_name = ".origin",
distance_col_name = ".distance",
overwrite = FALSE
)
The sorted data.frame
(tibble
) / vector
.
data.frame
or vector
.
Column(s) to create sorting factor by.
When `NULL`
and `data`
is a data.frame
,
the row numbers are used.
Coordinates of the origin to calculate distances to.
A scalar to use in all dimensions
or a vector
with one scalar per dimension.
N.B. Ignored when `origin_fn`
is not `NULL`
.
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()
Whether to shuffle elements with the same distance to the origin. (Logical)
Whether to order by decreasing distances to the origin. (Logical)
Name of new column with the origin coordinates. If `NULL`
, no column is added.
Name of new column with the distances to the origin. If `NULL`
, no column is added.
Whether to allow overwriting of existing columns. (Logical)