Skip to contents

Computes similarity scores between two or more lists of factors or enums. Implements both exact matching methods for precise category equivalence and order-preserving comparisons.

Usage

same_factor(..., method = c("exact", "order"), levels = NULL, digits = 3)

Arguments

...

Lists of categorical values (character or factor) to compare.

method

Character vector of similarity method (default: c("exact", "order")).

levels

Optional character vector of all allowed levels for comparison. If not provided, only "exact" method will be used.

digits

Number of digits to round results (default: 3).

Value

An S3 object of type "similar_factor" containing:

  • scores: Numeric similarity scores by method and comparison

  • summary: Summary statistics by method and comparison

  • methods: Methods used for comparison

  • list_names: Names of compared lists

  • levels: Levels used for categorical comparison

Examples

f1 <- list("R", "R", "Python")
f2 <- list("R", "Python", "R")

result <- same_factor(f1, f2)
#>  Skipping 'order' method as factor levels are not ordered
#>  Computed exact scores for "f1_f2" [mean: 0.333]