cbn_cosine.RdThis function calculates the cosine similarity matrix between all
rows of a matrix x. When x and y are vectors
it calculates the cosine similarity between them. When x
is a vector and y is a matrix it calculates the cosine
between x and each row of y.
cbn_cosine(x, y = NULL)
| x | A vector or a matrix (e.g., a document-term matrix). |
|---|---|
| y | A vector with compatible dimensions to x. If NULL, use all columns of |
The original code is from the cosine function by
Fridolin Wild (f.wild@open.ac.uk) in the lsa package.
An ncol(x) by ncol(x) matrix of cosine similarities, a scalar
cosine similarity, or a vector of cosine simialrities of length nrow(y).
This code is taken directly from the lsa package but adjusted to
operate rowwise.