View source: R/distanceToTarget.R
distanceToTarget | R Documentation |
Given a dataset of points, it computes the Euclidean distances from each point to a specified target point. The function also identifies contiguous segments of points that fall within a specified radius around the target.
distanceToTarget(data, target, targetRadious = 0)
data |
A matrix or data frame where each row represents a point in multi-dimensional space. |
target |
A numeric vector representing the coordinates of the target point. |
targetRadious |
A numeric value indicating the radius around the target point. Points within this radius are considered to be close to the target. Default is 0. |
A list containing:
distance |
A numeric vector of distances from each point in 'data' to the 'target'. |
r |
A list with two components: 'start', indicating the starting indices of contiguous segments of points within the target radius, and 'length', indicating the lengths of these segments. |
target_radious |
The radius around the target point. |
# Create an example data matrix
data <- matrix(c(1, 1, 2, 2, 3, 3), ncol = 2, byrow = TRUE)
target <- c(2, 2)
result <- distanceToTarget(data, target, targetRadious = 0)
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.