Calculate the Jaccard index between two sets.
Arguments
- x, y
vectors representing the two sets.
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