Learn R Programming

ribiosUtils (version 1.5-6)

naivePairwiseDist: Calculate pairwise distances between each pair of items in a list

Description

Calculate pairwise distances between each pair of items in a list

Usage

naivePairwiseDist(list, fun = jaccardIndex)

Arguments

list

A list

fun

A function that receives two vectors (such as jaccardIndex) and returns a number (scale)

Value

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

This function is inefficient compared with matrix-based methods. It is exported just for education and for verifying results of matrix-based methods.

Examples

Run this code
# NOT RUN {
myList <- list(first=LETTERS[3:5], second=LETTERS[1:3], third=LETTERS[1:5], fourth=LETTERS[6:10])
naivePairwiseDist(myList, fun=jaccardIndex)
## despite of the name, any function that returns a number can work
naivePairwiseDist(myList, fun=jaccardDistance)

# }

Run the code above in your browser using DataLab