cendist: Compute distances from centroid

Description Usage Arguments Details Value Methods (by class) Special cases Column specification

View source: R/fun_cendist.R

Description

Generic function that, given a set of pionts, finds distances between them and their centroid. Calls centroid and euclidean.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cendist(x, ...)

## S3 method for class 'numeric'
cendist(x, ...)

## S3 method for class 'matrix'
cendist(x, ...)

## S3 method for class 'data.frame'
cendist(x, ...)

## S3 method for class 'grouped_df'
cendist(x, ...)

Arguments

x

numeric vector, matrix or data frame

...

for data frame method, columns that store cooridinates

Details

A set of coordinates in n-dimensional space can be provided as a matrix or a data frame with points listed in rows and dimensions listed in columns (see Column specification). First the centroid coordinates is found by centroid and then the point-centroid distances are computed by euclidean.

Value

numeric vector of distances

Methods (by class)

Special cases

For a 1-dimensional set (one column matrix) deviations from the mean are returned.

For a single point (one row matrix) expect Value to be 0.

Any missing coordinates (NAs) will derail distance calculation for that point.

Column specification

Matrices are accepted as is, all columns are considered. If x is a data frame, columns that carry coordinates may be specified. They can be given as strings, bare names or numerical indices but they must all be specified in the same way. Also, each column must be specified separately, vectors are not accepted. If no columns are specified, all numeric ones are considered.


olobiolo/centroidr documentation built on Dec. 3, 2019, 12:55 p.m.