| euclidean_distance | R Documentation |
A function to calculate the Euclidean distance between two vectors.
euclidean_distance(.data, .x, .y, .pull_vector = FALSE)
.data |
A data frame |
.x |
A numeric vector |
.y |
A numeric vector |
.pull_vector |
A boolean of TRUE or FALSE. Default is FALSE which will augment the distance to the data frame. TRUE will return a vector of the distances as the return. |
A function to calculate the Euclidean distance between two vectors. It uses
the formula sqrt((x - lag(x))^2 + (y - lag(y))^2). The function uses augments
the data frame with a new column called distance.
A numeric Vector of ditances
Steven P. Sanderson II, MPH
Other Vector Function:
cgmean(),
chmean(),
ckurtosis(),
cmean(),
cmedian(),
crange(),
csd(),
cskewness(),
cvar(),
kurtosis_vec(),
rw_range(),
skewness_vec()
set.seed(123)
df <- rw30()
euclidean_distance(df, step_number, y)
euclidean_distance(df, step_number, y, TRUE) |> head(10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.