Session Ready
Exercise

Using the dist() function

Using the Euclidean formula manually may be practical for 2 observations but can get more complicated rather quickly when measuring the distance between many observations.

The dist() function simplifies this process by calculating distances between our observations (rows) using their features (columns). In this case the observations are the player positions and the dimensions are their x and y coordinates.

Note: The default distance calculation for the dist() function is Euclidean distance

Instructions
100 XP
  • Calculate the distance between two players using the dist() function for the data frame two_players
  • Calculate the distance between three players for the data frame three_players