centroid.scaled.distances: Calculate the matrix of distances between shape coordinates,...

View source: R/centroid.scaled.distances.R

centroid.scaled.distancesR Documentation

Calculate the matrix of distances between shape coordinates, scaled by centroid size

Description

Calculate the matrix of distances between shape coordinates, scaled by centroid size

Usage

centroid.scaled.distances(m, scale = TRUE, symmetrical = FALSE)

Arguments

m

A matrix containing XY shape coordinates for p landmarks

scale

A logical argument for whether to scale the distances by centroid size

symmetrical

A logical argument for whether to keep the output matrix symmetrical. If symmetrical = FALSE (the default) then the upper triangle and diagonal cells will be NA.

Value

Returns a matrix, with dimensions p x p.

Source

Dave Angelini david.r.angelini@gmail.com [aut, cre]

Examples

x <- matrix(c(9,49, 24,54, 51,28, 81,54, 81,23, 86,32), ncol = 2, byrow = TRUE)

centroid.scaled.distances(x)
centroid.scaled.distances(x, symmetrical = TRUE)
centroid.scaled.distances(x, symmetrical = TRUE, scale = FALSE)

# cross validation
df <- data.frame(matrix(nrow = dim(x)[1], ncol = dim(x)[1]))
for (i in (1:dim(x)[1])) {
  df[i,] <- unlist(apply(x, 1, distance, XY=x[i,]))
}
df


aphanotus/borealis documentation built on Nov. 4, 2022, 8:44 p.m.