ft_pairs | R Documentation |
Creates all unique pairwise combinations between factor_vec of a vector, with options for references, symmetry, NA handling, custom filtering, and output formats. Automatically handles factors by converting them to vectors and removes extra spaces from factor_vec before processing.
ft_pairs(
factor_vec,
ref = NULL,
symmetric = TRUE,
include_na = FALSE,
include_self = FALSE,
filter_fn = NULL,
pre_fn = trimws,
sort_by = "none",
output_format = "data.frame"
)
factor_vec |
A vector containing the factor_vec to compare. Can be of any type (character, numeric, factor, etc.). |
ref |
Optional. A vector containing the reference factor_vec. If NULL (default), comparisons are made within the |
symmetric |
Logical. If |
include_na |
Logical. If |
include_self |
Logical. If |
filter_fn |
Optional. A custom function to filter the pairs. Should accept a data frame and return a logical vector. |
pre_fn |
Optional. A function to preprocess the factor_vec before comparison (e.g., |
sort_by |
Character string specifying how to sort the output. Options are |
output_format |
Character string specifying the output format. Options are |
A data frame, list, matrix, or tibble containing pairwise comparisons between factor_vec.
# Example vector with extra spaces and mixed case
vec <- c(' A', 'b ', ' C ', 'D')
# Generate pairwise comparisons within vec
ft_pairs(vec)
# Use a custom preprocessing function to convert factor_vec to lower case
ft_pairs(vec, pre_fn = function(x) tolower(trimws(x)))
ft_pairs(vec, ref = c("A","C"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.