Learn R Programming

iTOP (version 1.0.2)

jaccard: Jaccard similarity.

Description

Computes the Jaccard similarity between x and y. When both x and y only contain zeroes, the Jaccard similarity it not defined. This function returns zero for that specific case.

Usage

jaccard(x, y)

Arguments

x

A vector of zeroes and ones.

y

A vector of zeroes and ones.

Value

The Jaccard similarity between x and y.

Examples

Run this code
# NOT RUN {
set.seed(2)
n = 100
x = rbinom(n, 1, 0.5)
y = rbinom(n, 1, 0.5)
jaccard(x, y)
# }

Run the code above in your browser using DataLab