| Title: | Creates 2D animations of soccer tracking data |
|---|---|
| Description: | This packages allows you to create 2D animations of soccer tracking data in addition to do some player calculations and team possession stats. |
| Authors: | person(given = "Ismael", family = "Gómez", role = c("aut", "cre"), email = "[email protected]") |
| Maintainer: | Ismael Gómez Schmidt <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-10-19 06:44:12 UTC |
| Source: | https://github.com/Dato-Futbol/soccerAnimate |
Searches time ocurrence and other information of specific events
events_info(data, events = c("SHOT", "GOAL", "FREE KICK", "CORNER KICK"))events_info(data, events = c("SHOT", "GOAL", "FREE KICK", "CORNER KICK"))
data |
event dataframe previously loaded |
events |
one or more events to search (options: SHOT, GOAL, FREE KICK, CORNER KICK) |
dataframe with searched events and their specific info
Reads and converts both the home and away team rawdata to tidy data (long format) and join them. Currently only Metrica Sports data format is supported
get_tidy_data( home_team_file, away_team_file, provider = "Metrica", add_velocity = T, pitch_long = 105, pitch_width = 68 )get_tidy_data( home_team_file, away_team_file, provider = "Metrica", add_velocity = T, pitch_long = 105, pitch_width = 68 )
home_team_file |
set the filename which contains the data of the home team |
away_team_file |
set the filename which contains the data of the away team |
provider |
set the name of the tracking data provider which defines the data format |
add_velocity |
A boolean variable to set if the players velocities should to be added |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
The dataframe with all tidy data joined (long format)
Creates 2D animations using soccer tracking data allowing you export it as gif file
player_animate( tidy_data, target_player, ini_frame, end_frame, player_col = "#ffc300", method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", title = "", subtitle = "", provider = "Metrica", show_anim = T, export_gif = F, gif_name = "animation" )player_animate( tidy_data, target_player, ini_frame, end_frame, player_col = "#ffc300", method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", title = "", subtitle = "", provider = "Metrica", show_anim = T, export_gif = F, gif_name = "animation" )
tidy_data |
the processed dataframe ready to do visualizations. It could be obtained using either get_tidy_data() or process_catapult() functions. |
target_player |
player whose actions will be highlighted |
ini_frame |
the frame to consider as the initial point for the animation |
end_frame |
the frame to consider as the ending point for the animation |
player_col |
color to highlight the target player actions |
method |
four different approaches to visualize: base (default), convexhull, voronoi, delaunay |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
pitch_fill |
color used to fill the pitch |
pitch_lines_col |
color used for lines of the pitch |
home_team_col |
color used to fill the players of the home team |
away_team_col |
color used to fill the players of the away team |
title |
graph title |
subtitle |
graph subtitle |
provider |
set the name of the tracking data provider which defines the data format |
show_anim |
should the animation be shown on the viewer? (T/F) |
export_gif |
should the animation be exported as gif file? (T/F) |
gif_name |
the name of the exported gif file |
animated gif on viewer and/or as output file
Creates a 2D static plot marking the selected frames of a specific player
player_plot( tidy_data, target_player, start_frames, end_frames = NULL, pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", action_name = "sprints", action_col = "purple", label_col = "white", export_png = F )player_plot( tidy_data, target_player, start_frames, end_frames = NULL, pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", action_name = "sprints", action_col = "purple", label_col = "white", export_png = F )
tidy_data |
the processed dataframe ready to do visualizations. It could be obtained using the function get_tidy_data(). |
target_player |
the player whose selected frames will be marked |
start_frames |
vector with the selected frames focused on when specific actions start |
end_frames |
vector with the selected frames focused on when specific actions end |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
pitch_fill |
color used to fill the pitch |
pitch_lines_col |
color used for lines of the pitch |
action_name |
action name(s) to be highlighted |
action_col |
color used for the frames marking related to a specific action |
label_col |
color used for labels showing the Time when actions start |
export_png |
should the plot be exported as png file? (T/F) |
plot with the selected frames of a player on Plots panel and/or as png output file
Calculate multiple players stats based on tracking data. It includes Minutes played, distance, average/max speed in addition to distance splitted by different speed ranges.
players_stats(data, speed_ranges = c("laurie", "perf"))players_stats(data, speed_ranges = c("laurie", "perf"))
data |
dataframe with the already processed tracking data in long format |
speed_ranges |
character to set what kind of speed ranges has to be considered: a) "laurie": walking, jogging, running, sprinting; b) "perf": low speed activity, high speed running, very high speed running and sprinting |
dataframe with the results
Create a graph to compare players stats for a specific team
players_stats_graph( data, team = c("home", "away"), var = "ranges", export_png = F )players_stats_graph( data, team = c("home", "away"), var = "ranges", export_png = F )
data |
dataframe with the players stats |
team |
team to graph "home" or "away" |
var |
variable to graph, default value = "ranges" for speed ranges |
export_png |
should the graph be exported as PNG file? (T/F) |
dataframe with the results
Creates 2D animations using soccer tracking data allowing you export it as gif file
soccer_animate( tidy_data, ini_time, end_time, method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", title = "", subtitle = "", provider = "Metrica", show_anim = T, export_gif = F, gif_name = "animation" )soccer_animate( tidy_data, ini_time, end_time, method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", title = "", subtitle = "", provider = "Metrica", show_anim = T, export_gif = F, gif_name = "animation" )
tidy_data |
the processed dataframe ready to do visualizations. It could be obtained using either get_tidy_data() or process_catapult() functions. |
ini_time |
the time in seconds of tracking data to consider as initial time of the animation |
end_time |
the time in seconds of tracking data to consider as ending time of the animation |
method |
four different approaches to visualize: base (default), convexhull, voronoi, delaunay |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
pitch_fill |
colour used to fill the pitch |
pitch_lines_col |
colour used for lines of the pitch |
home_team_col |
colour used to fill the players of the home team |
away_team_col |
colour used to fill the players of the away team |
title |
graph title |
subtitle |
graph subtitle |
provider |
set the name of the tracking data provider which defines the data format |
show_anim |
should the animation be shown on the viewer? (T/F) |
export_gif |
should the animation be exported as gif file? (T/F) |
gif_name |
the name of the exported gif file |
animated gif on viewer and/or as output file
Creates a 2D static plot of a unique frame from soccer tracking data
soccer_plot( tidy_data, target_frame, method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", provider = "Metrica", export_png = F, png_name = "plot", title = "", subtitle = "" )soccer_plot( tidy_data, target_frame, method = "base", pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", home_team_col = "white", away_team_col = "#dd3497", provider = "Metrica", export_png = F, png_name = "plot", title = "", subtitle = "" )
tidy_data |
the processed dataframe ready to do visualizations. It could be obtained using either get_tidy_data() or process_catapult() functions. |
target_frame |
the unique frame of the tracking data to visualize |
method |
four different approaches to visualize: base, convexhull, voronoi, delaunay |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
pitch_fill |
colour used to fill the pitch |
pitch_lines_col |
colour used for lines of the pitch |
home_team_col |
colour used to fill the players of the home team |
away_team_col |
colour used to fill the players of the away team |
provider |
set the name of the tracking data provider which defines the data format |
export_png |
should the plot be exported as png file? (T/F) |
png_name |
the name of the exported gif file |
title |
graph title |
subtitle |
graph subtitle |
soccer plot on Plots panel and/or as output file
Creates a 2D team visualization on a team level with avg. positioning splitting by ON/OFF possesion
soccer_plot_poss( tidy_data, events_path, team = c("Home", "Away"), pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", target_team_col = "#7209b7", opp_team_col = "#06d6a0", on_ball_col = "white", off_ball_col = "#dd3497", export_png = F, png_name = "plot", annotation = "NA" )soccer_plot_poss( tidy_data, events_path, team = c("Home", "Away"), pitch_long = 105, pitch_width = 68, pitch_fill = "#74a9cf", pitch_lines_col = "lightgrey", target_team_col = "#7209b7", opp_team_col = "#06d6a0", on_ball_col = "white", off_ball_col = "#dd3497", export_png = F, png_name = "plot", annotation = "NA" )
tidy_data |
the processed dataframe ready to do visualizations. It could be obtained using either get_tidy_data() or process_catapult() functions. |
events_path |
path where the CSV file with eventing data is located |
team |
target team |
pitch_long |
long of the pitch in meters |
pitch_width |
width of the pitch in meters |
pitch_fill |
colour used to fill the pitch |
pitch_lines_col |
colour used for lines of the pitch |
target_team_col |
colour used to fill the border of players circles of the target team (top position on the graph) |
opp_team_col |
colour used to fill the border of players circles of the opponent team (bottom position on the graph) |
on_ball_col |
colour used to fill the players when their team was ON possession |
off_ball_col |
colour used to fill the players when their team was OFF possession |
export_png |
should the plot be exported as png file? (T/F) |
png_name |
the name of the exported gif file |
annotation |
'NA' by default. If "depth" is setted, vertical lines with lowest defender and highest forward will be added |
soccer plot on 'Plots' panel and/or as output PNG file
Get the start/end time of the sprints that every player made
sprints_info(data, team = c("home", "away"))sprints_info(data, team = c("home", "away"))
data |
dataframe with the already processed tracking data in long format |
team |
team to graph "home" or "away" |
dataframe with the results