Wrapper for running extreme pairing
extreme_pairing_rearranger_(
data,
col = NULL,
unequal_method = "middle",
order_by_aggregates = FALSE,
shuffle_members = FALSE,
shuffle_pairs = FALSE,
num_pairings = 1,
balance = "mean",
factor_name = ".pair",
overwrite = FALSE
)
The sorted data.frame
(tibble
) / vector
.
Optionally with the sorting factor(s) added.
When `data`
is a vector
and `factor_name`
is `NULL`
,
the output will be a vector
. Otherwise, a data.frame
.
data.frame
or vector
.
Column to create sorting factor by.
When `NULL`
and `data`
is a data.frame
,
the row numbers are used.
Method for dealing with an
unequal number of rows/elements in `data`
.
One of: first
, middle
or last
The first group will have size 1
.
Example:
The ordered column values:
c(1, 2, 3, 4, 5)
Creates the sorting factor:
c(
1
, 2, 3, 3, 2)
And are ordered as:
c(
1
, 2, 5, 3, 4)
The middle group will have size 1
.
Example:
The ordered column values:
c(1, 2, 3, 4, 5)
Creates the sorting factor:
c(1, 3,
2
, 3, 1)
And are ordered as:
c(1, 5,
3
, 2, 4)
The last group will have size 1
.
Example:
The ordered column values:
c(1, 2, 3, 4, 5)
Creates the sorting factor:
c(1, 2, 2, 1,
3
)
And are ordered as:
c(1, 4, 2, 3,
5
)
Whether to order the pairs from initial pairings (first `num_pairings` - 1
)
by their aggregate values instead of their pair identifiers.
N.B. Only used when `num_pairings` > 1
.
Whether to shuffle the order of the group members within the groups. (Logical)
Whether to shuffle the order of the pairs. Pair members remain together. (Logical)
Number of pairings to perform (recursively). At least 1
.
Based on `balance`
, the secondary pairings perform extreme pairing on either the
sum, absolute difference, min, or max of the pair elements.
What to balance pairs for in a given secondary pairing.
Either "mean"
, "spread"
, "min"
, or "max"
.
Can be a single string used for all secondary pairings
or one for each secondary pairing (`num_pairings` - 1
).
The first pairing always pairs the actual element values.
Pairs have similar means. The values in the pairs from the previous pairing
are aggregated with `sum()`
and paired.
Pairs have similar spread (e.g. standard deviations).
The values in the pairs from the previous pairing
are aggregated with `sum(abs(diff()))`
and paired.
Pairs have similar minimum / maximum values. The values in the pairs from the previous pairing
are aggregated with `min()`
/ `max()`
and paired.
Name of new column with the sorting factor.
If `NULL`
, no column is added.
Whether to allow overwriting of existing columns. (Logical)