cosine: Cosine Similarity

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cosine.r

Description

Compute the cosine similarity matrix efficiently. The function syntax and behavior is largely modeled after that of the cosine() function from the lsa package, although with a very different implementation.

Usage

1
2
3
cosine(x, y, use = "everything", inverse = FALSE)

tcosine(x, y, use = "everything", inverse = FALSE)

Arguments

x

A numeric dataframe/matrix or vector.

y

A vector (when x is a vector) or missing (blank) when x is a matrix.

use

The NA handler, as in R's cov() and cor() functions. Options are "everything", "all.obs", and "complete.obs".

inverse

Logical; should the inverse covariance matrix be returned?

Details

See ?coop-package for implementation details.

Value

The n\times n matrix of all pair-wise vector cosine similarities of the columns.

Author(s)

Drew Schmidt

See Also

sparsity

Examples

1
2
3
4
x <- matrix(rnorm(10*3), 10, 3)

coop::cosine(x)
coop::cosine(x[, 1], x[, 2])

coop documentation built on Sept. 19, 2021, 5:07 p.m.