similarity | R Documentation |
Compute the similarity between two vectors.
similarity(x, y, f = "cosine", ceiling = 1e+07, ...)
x |
A numeric vector. |
y |
A numeric vector. |
f |
Similarity function. One among "cosine" (default), "jaccard" (for dichotomous vectors only), "pearson", "spearman", "kendall", or "euclidean". |
ceiling |
If |
... |
Currently ignored. |
A numeric value corresponding to the similarity coefficient.
Fernando Palluzzi fernando.palluzzi@gmail.com
Leydesdorff L (2005). Similarity Measures, Author Cocitation Analysis,and Information Theory. In: JASIST 56(7), pp.769-772. <https://doi.org/10.48550/arXiv.0911.4292>
jaccard
,
euclidean
# Sample two random ultrasound profiles from the default dataset x <- mosaic::sample(mpm.us, 1, replace = FALSE, prob = NULL) x <- as.numeric(x[, 2:15]) y <- mosaic::sample(mpm.us, 1, replace = FALSE, prob = NULL) y <- as.numeric(y[, 2:15]) # Compute the cosine similarity r <- similarity(x, y) print(r)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.