JoGall / soccermatics

Tools for visualisation and analysis of soccer tracking and event data
308 stars 36 forks source link

Hi Ryo, #24

Open ronitmotiwale opened 4 years ago

ronitmotiwale commented 4 years ago

Hi Ryo,

This is an old issue which I am quoting:(My main issue is all the way down)

The issue here is needing to process the raw data retrieved by get.matchFree() using other StatsBombR functions like cleanlocations(). I made a helper function in a fork of the package here to automate this process if you're interested.

Once you have the cleaned data containing variables location.x and location.y, you need to use the soccerTransform() function with option method = "statsbomb" to convert the data from StatsBomb coordinates (1 <= x <= 120, 1 <= y <= 80) to metre units for plotting with soccermatics (by default this function uses 105m x 68m for pitch length and width, as do other soccermatics functions, but you can specify alternative pitch dimensions).

Code should look something like this then:

library(dplyr)

# get Japan matches
WC_Matches <- StatsBombR::FreeMatches(43)
JPN_Matches <- WC_Matches %>% 
  filter(home_team.home_team_id == 778 | away_team.away_team_id == 778)

# get all StatsBomb data
jp <- StatsBombR::allinfo(JPN_Matches)

# transform x,y-coords to real-world units for compatability with soccermatics
jp <- jp %>% 
  soccermatics::soccerTransform(method = "statsbomb")

# shotmap for multiple matches
jp %>% 
  filter(player.name == "Takashi Inui") %>% 
  soccermatics::soccerShotmap(theme = "grey",
                              title = "Takashi Inui",
                              subtitle = "World Cup 2018")

rplot08

# passmap for one match
jp_sen <- jp %>% 
  filter(match_id == 7556)

jp_sen %>% 
  filter(team.name == "Japan") %>% 
  soccermatics::soccerPassmap(fill = "lightblue", arrow = "r", theme = "light",
                              title = "Japan (vs. Senegal, World Cup 2018)")

rplot10

Hope that helps!

Originally posted by @JoGall in https://github.com/JoGall/soccermatics/issues/14#issuecomment-439712501

I faced a similar problem so I tried to do what you have mentioned here, JoGall. I was working on France vs Croatia game. wc_game<- FreeMatches(Comp) France <- wc_game%>% filter(match_id == 8658) fr <- StatsBombR::allinfo(France)

It keeps giving me an error in the second part(allinfo part). Error: 'allinfo' is not an exported object from 'namespace:StatsBombR'

Please suggest something