Learn R Programming

jmotif (version 1.3.2)

cosine_dist: Computes the cosine distance between numeric vectors (1 minus cosine similarity).

Description

Computes the cosine distance between numeric vectors (1 minus cosine similarity).

Usage

cosine_dist(m)

Value

A dist object of pairwise cosine distances.

Arguments

m

the data matrix (rows are vectors).

Examples

Run this code
a <- c(2, 1, 0, 2, 0, 1, 1, 1)
b <- c(2, 1, 1, 1, 1, 0, 1, 1)
sim <- cosine_dist(rbind(a,b))

Run the code above in your browser using DataLab