Exercise

Calculate & plot the distance between two players

You've obtained the coordinates relative to the center of the field for two players in a soccer match and would like to calculate the distance between them.

In this exercise you will plot the positions of the 2 players and manually calculate the distance between them by using the Euclidean distance formula.

Instructions

100 XP
  • Plot their positions from the two_players data frame using ggplot.
  • Extract the positions of the players into two data frames player1 and player2.
  • Calculate the distance between player1 and player2 by using the Euclidean distance formula $$\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}$$.