centroid: Find centroid

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

View source: R/fun_centroid.R

Description

Generic function that, given a set of pionts, finds their centroid.

Usage

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

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

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

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

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

Arguments

x

matrix or data frame with observations in rows and dimensions in columns

...

for data frame method, columns that store cooridinates

Details

Centroid coordinates are derived as average coordinates of all points in respective dimensions. If a point is missing a coordinate, the remainig dimensions are still considered. Methods exist for matrix and data frame.

The data frame method isolates relevant columns as a matrix and calls the matrix method.

Value

numeric vector of centroid coordinates

Methods (by class)

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.