View source: R/sim_calculate.R
sim_calculate_ij | R Documentation |
sim_calculate_ij
calculates similarities given pairs of rows.
sim_calculate_ij(
population,
index,
method = NULL,
annotation_prefix = "Metadata_",
...
)
population |
data.frame with annotations (a.k.a. metadata) and observation variables. |
index |
data.frame with at least two columns |
method |
optional character string specifying method for
to calculate similarity. |
annotation_prefix |
optional character string specifying prefix for annotation columns. |
... |
arguments passed downstream for parallel processing. |
data.frame which is the same as index
, but with a new
column sim
containing similarities, and with the diagonals filtered out.
suppressMessages(suppressWarnings(library(magrittr)))
population <- tibble::tribble(
~Metadata_group, ~x, ~y, ~z,
1, -1, 5, -5,
2, 0, 6, -4,
3, 7, -4, 3,
4, 14, -8, 6
)
n <- nrow(population)
index <-
expand.grid(id1 = seq(n), id2 = seq(n), KEEP.OUT.ATTRS = FALSE)
matric::sim_calculate_ij(population, index, method = "cosine")
attr(index, "metric_metadata") <- list(method = "cosine")
matric::sim_calculate_ij(population, index)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.