Calculate Euclidean between two sets of matrices, e.g. Procrustes-aligned shape coordinates

calc_ed(coords_matrix, pairs_table)

Arguments

coords_matrix

Table containing point coordinates. Rows correspond to specimen, columns correspond to x/y(/z) coordinates. Rownames need to contain IDs of specimen.

pairs_table

Table containing IDs of specimen for which Euclidean distance is to be calculated; column 1: specimen A, column 2: specimen B. Note that IDs in the two tables need to conform; e.g., character in both coords_matrix and pairs_table.

Value

Returns table listing specimen and their Euclidean distance

Examples

my_data <- tibble::tibble( IDs = c(paste0("specimen_", 1:3)), LM1_x = c(1, 2, 5), LM1_y = c(1, 1, 1), LM2_x = c(1, 2, 5), LM2_y = c(3, 2.5, 2.5), LM3_x = c(3, 3, 6), LM3_y = c(2, 2.5, 2.5) ) %>% tibble::column_to_rownames("IDs") pairs <- t(combn(paste0("specimen_", 1:3), 2)) %>% as.data.frame(stringsAsFactors = FALSE) calc_ed(my_data, pairs)
#> # A tibble: 3 x 3 #> A B EuclideanDistance #> <chr> <chr> <dbl> #> 1 specimen_1 specimen_2 1.58 #> 2 specimen_1 specimen_3 6.44 #> 3 specimen_2 specimen_3 5.20