euclidean_distance {RandomWalker} | R Documentation |
Distance Calculations
Description
A function to calculate the Euclidean distance between two vectors.
Usage
euclidean_distance(.data, .x, .y, .pull_vector = FALSE)
Arguments
.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. |
Details
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
.
Value
A numeric Vector of ditances
Author(s)
Steven P. Sanderson II, MPH
See Also
Other Vector Function:
cgmean()
,
chmean()
,
ckurtosis()
,
cmean()
,
cmedian()
,
crange()
,
csd()
,
cskewness()
,
cvar()
,
kurtosis_vec()
,
rw_range()
,
skewness_vec()
Examples
set.seed(123)
df <- rw30()
euclidean_distance(df, x, y)
euclidean_distance(df, x, y, TRUE) |> head(10)
[Package RandomWalker version 0.1.0 Index]