Skip to contents

Calculate the Jaccard index between two sets.

Usage

jaccard(x, y)

Arguments

x, y

vectors representing the two sets.

Value

<numeric> value

Details

The Jaccard index, also known as the Jaccard similarity coefficient, measures the similarity between two sets by comparing the size of their intersection to the size of their union.

Examples

jaccard(c(1, 2, 3), c(2, 3, 4))
#> [1] 0.5

jaccard(factor(c(1, 2, 3)), factor(c(2, 3, 4)))
#> [1] 0.5

jaccard(c(1), c())
#> [1] 0