Replacement for the bare combn(conditions, 2) the report templates used to
call: utils::combn() errors with n < m when a subset happens to contain a
single Condition, which aborted the whole render. This returns an empty
list in that case, so the calling section can print a note and move on.
Value
A list of length-2 character vectors, named "<Cond1>_vs_<Cond2>";
empty (and, with self = TRUE, self-comparisons only) when fewer than two
conditions are present.
Examples
condition_pairs(c("CTRL", "TREAT", "OTHER"))
#> $CTRL_vs_TREAT
#> [1] "CTRL" "TREAT"
#>
#> $CTRL_vs_OTHER
#> [1] "CTRL" "OTHER"
#>
#> $TREAT_vs_OTHER
#> [1] "TREAT" "OTHER"
#>
condition_pairs("CTRL") # empty list, no error
#> list()
condition_pairs("CTRL", self = TRUE) # just CTRL vs CTRL
#> $CTRL_vs_CTRL
#> [1] "CTRL" "CTRL"
#>