find_most_similar_columns {AnimalSequences} | R Documentation |
Find Most Similar Columns in a Distance Matrix
Description
This function identifies the most similar columns for each column in a distance matrix. For each column, it finds the columns with the smallest distances (i.e., most similar) based on the given number of similar columns to retrieve.
Usage
find_most_similar_columns(distance_matrix, n_similar = 3)
Arguments
distance_matrix |
A numeric matrix where the distance between columns is represented. The rows and columns should correspond to the same set of entities. |
n_similar |
An integer specifying the number of most similar columns to find for each column. Default is 3. |
Value
A list of character vectors. Each element of the list corresponds to a column in the distance matrix and contains the column names of the most similar columns.
Examples
# Create a sample distance matrix
distance_matrix <- matrix(c(0, 1, 2, 1, 0, 3, 2, 3, 0),
nrow = 3,
dimnames = list(NULL, c("A", "B", "C")))
# Find the 2 most similar columns for each column
find_most_similar_columns(distance_matrix, n_similar = 2)
[Package AnimalSequences version 0.2.0 Index]