Learn R Programming

ribiosUtils (version 1.5-6)

pairwiseJaccardIndex: Calculate pairwise Jaccard Indices between each pair of items in a list

Description

Calculate pairwise Jaccard Indices between each pair of items in a list

Usage

pairwiseJaccardIndex(list)

pairwiseJaccardDistance(list)

Arguments

list

A list

Value

A symmetric matrix of dimension mxm, where m is the length of the list

pairwiseJaccardDistance is defined as 1-pairwiseJaccardIndex.

Examples

Run this code
# NOT RUN {
myList <- list(first=LETTERS[3:5], second=LETTERS[1:3], third=LETTERS[1:5], fourth=LETTERS[6:10])
pairwiseJaccardIndex(myList)

poormanPJI <- function(list) {
  sapply(list, function(x) sapply(list, function(y) jaccardIndex(x,y)))
}
stopifnot(identical(pairwiseJaccardIndex(myList), poormanPJI(myList)))

# }

Run the code above in your browser using DataLab