euclidDist {utilitiesR}R Documentation

return euclidean distance between successive rows in a matrix.

Description

return euclidean distance between successive rows in a matrix.

Usage

  euclidDist(m, cols = FALSE, circular = FALSE)

Arguments

m

An nxm matrix where there are n points in R^m, and we want to find the distance between successive rows (points). i.e., one point per row.

circular

boolean, whether to also calculate the distance between the last and first point.

cols

If this is TRUE, the matrix is mxn instead (each point is a column)

Value

a vector of length (n-1) containing the distance between successive points in "m".

Examples

# make a matrix of 4 points in 2D.
m <- array(runif(4*2),dim=c(4,2))
euclidDist(m)            # dist between rows
euclidDist(m,circular=TRUE) # dist between rows including 4 to 1.
euclidDist(m,cols=TRUE)     # dist between cols

[Package utilitiesR version 1.7 Index]