calcED: Calculate Euclidean distance

Description Usage Arguments Value Examples

View source: R/calcED.R

Description

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

Usage

1
calcED(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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

calcED(my_data, pairs)

iholzleitner/demopckg documentation built on Oct. 7, 2020, 12:26 a.m.