View source: R/selection_helpers.R
closest_to_centroid | R Documentation |
Detection of the closest points to the centroid of a cloud of points
closest_to_centroid(data, x_column, y_column, space, n = 1, id_column = NULL)
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 |
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.
# Data
m_matrix <- read_master(system.file("extdata/m_matrix.rds",
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.