Learn R Programming

UAHDataScienceO (version 1.0.0)

euclidean_distance: euclidean_distance

Description

This function calculates the euclidean distance between 2 points. They must have the same number of dimensions

Usage

euclidean_distance(p1, p2)

Value

Euclidean Distance calculated between the two N-dimensional points

Arguments

p1

One of the points that will be used by the algorithm with N dimensions

p2

The other point that will be used by the algorithm with N dimensions

Author

Andres Missiego Manjon

Examples

Run this code
inputData = t(matrix(c(3,2,3.5,12,4.7,4.1,5.2,
4.9,7.1,6.1,6.2,5.2,14,5.3),2,7,dimnames=list(c("r","d"))));
inputData = data.frame(inputData);
point1 = inputData[1,];
point2 = inputData[4,];
distance = euclidean_distance(point1, point2);

Run the code above in your browser using DataLab