same_number {samesies} | R Documentation |
Compare Numerical Similarity Across Lists
Description
Computes similarity scores between two or more lists of numeric values using multiple comparison methods.
Usage
same_number(
...,
method = c("exact", "raw", "exp", "percent", "normalized", "fuzzy"),
epsilon = 0.05,
epsilon_pct = 0.02,
max_diff = NULL,
digits = 3
)
Arguments
... |
Two or more lists containing numeric values to compare |
method |
Character vector specifying similarity methods (default: all) |
epsilon |
Threshold for fuzzy matching (default: NULL for auto-calculation) |
epsilon_pct |
Relative epsilon percentile (default: 0.02 or 2%). Only used when method is "fuzzy" |
max_diff |
Maximum difference for normalization (default: NULL for auto-calculation) |
digits |
Number of digits to round results (default: 3) |
Details
The available methods are:
-
exact
: Binary similarity (1 if equal, 0 otherwise) -
percent
: Percentage difference relative to the larger value -
normalized
: Absolute difference normalized by a maximum difference value -
fuzzy
: Similarity based on an epsilon threshold -
exp
: Exponential decay based on absolute difference (e^-diff) -
raw
: Returns the raw absolute difference (|num1 - num2|) instead of a similarity score
Value
An S3 object containing:
-
scores
: A list of similarity scores for each method and list pair -
summary
: A list of statistical summaries for each method and list pair -
methods
: The similarity methods used -
list_names
: Names of the input lists -
raw_values
: The original input lists
Examples
nums1 <- list(1, 2, 3)
nums2 <- list(1, 2.1, 3.2)
result <- same_number(nums1, nums2)