dist2centroid: Distances to the Centroid

View source: R/centroid.R

dist2centroidR Documentation

Distances to the Centroid

Description

Given a set of x-y (or longitude-latitude) coordinates, this function computes their respective distance to the centroid (or center of mass) of the set.

Usage

dist2centroid(x, y, robust = FALSE, geo = FALSE)

Arguments

x

A vector of x (or longitude) coordinates.

y

A vector of y (or latitude) coordinates.

robust

A logical value indicating whether to compute the centroid as a simple average of the coordinates (FALSE, the default), or as the average of the coordinates weighted by the inverse of their mean pairwise distance to all other coordinates in the set (TRUE).

geo

A logical value indicating whether the locations are defined by geographic coordinates (pairs of longitude/latitude values). Default: FALSE.

Value

A vector of the same length as x and y corresponding to the individual distance of each point to the centroid of the set.

Author(s)

Simon Garnier, garnier@njit.edu

See Also

centroid

Examples

x <- rnorm(25)
y <- rnorm(25, sd = 3)
dist2centroid(x, y)


swarm-lab/swaRm documentation built on Dec. 3, 2023, 9:30 p.m.