View source: R/distanceTraveled.R
distanceTraveled | R Documentation |
Computes the cumulative distance between consecutive points in a given set of coordinates. It sums the Euclidean distances between each pair of adjacent points, providing the total distance traveled along the path defined by the points.
distanceTraveled(points)
points |
A matrix or data frame where each row represents a point with its coordinates (e.g., x and y). |
A numeric value representing the total distance traveled through the points.
# Define a set of points
points <- matrix(c(0, 0, 1, 1, 2, 0), ncol = 2, byrow = TRUE)
# Calculate the distance traveled
total_distance <- distanceTraveled(points)
# Print the total distance
print(total_distance)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.