closest_to_centroid: Detection of the closest points to the centroid of a cloud of...

Description Usage Arguments Value Examples

View source: R/selection_helpers.R

Description

Detection of the closest points to the centroid of a cloud of points

Usage

1
closest_to_centroid(data, x_column, y_column, space, n = 1, id_column = NULL)

Arguments

data

matrix or data.frame that contains at least two columns.

x_column

(character) the name of the x-axis.

y_column

(character) the name of the y-axis.

space

(character) space in which the thinning will be performed. There are two options available: "G", if it will be in geographic space, and "E", if it will be in environmental space.

n

(numeric) number of points that are close to the centroid to be detected. Default = 1.

id_column

(character or numeric) name or numeric index of the column in data containing identifiers of one or distinct sets of points. If, NULL, the default, only one set is assumed.

Value

A data.frame containing n rows corresponding to the point or points that are the closest to the centroid of all other points of reference.

Examples

1
2
3
4
5
6
7
8
# Data
data("m_matrix", package = "biosurvey")
data1 <- m_matrix$data_matrix

# Finding the closest point to the centroid
centroid <- closest_to_centroid(data1, x_column = "Longitude",
                                y_column = "Latitude", space = "G",
                                n = 1, id_column = NULL)

biosurvey documentation built on Sept. 16, 2021, 1:07 a.m.