Description Usage Arguments Value References Examples
View source: R/fc_velocity_polygon.R
This function computes summary statistics of velocities within a grid of polygons that cover the pitch dimensions
1 2 3 4 5 6 7 8 9 10 |
data |
A simple feature object. Event velocities should be variables in
|
metric |
A character vector of length one indicating which polygon velocity to compute. Should be one of "speed", "east_velocity", "west_velocity", "north_velocity", "south_velocity", "east_west_velocity", "north_south_velocity". |
match |
A character vector of match id values. Only required to define possession ids and sequences in multi-match data frames. |
fcn |
A summary function as a character vector. Typical values are "mean", "median", "sd", "IQR". |
... |
Arguments and their values related to |
shape |
A character vector of length one indicating the polygon type. Valid values include "square" and "hexagon". |
size |
A numeric vector of length one defining the size of the polygons |
preview_grid |
A logical vector of length one. A value of |
A simple feature object with a geometry
and summary statistic
as defined by arguments fcn
and metric
.
Pappalardo, L., Cintia, P., Rossi, A. et al. A public data set of spatio-temporal match events in soccer competitions. Sci Data 6, 236 (2019). https://doi.org/10.1038/s41597-019-0247-7
All public Wyscout data is available at https://figshare.com/collections/Soccer_match_event_dataset/4415000/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # load dplyr for examples
library(dplyr)
file_path <- system.file("extdata", "events_england.json", package = "scoutr")
events <- fc_read_events(file_path)
data <- events %>%
select(-starts_with("tag_")) %>%
fc_locations_transform(x = c("start_x", "end_x"), y = c("start_y", "end_y")) %>%
fc_sequence_possession(event_var = "event_name", team_var = "team_id") %>%
fc_velocity_event(start_loc = c("start_x", "start_y"), end_loc = c("end_x", "end_y")) %>%
fc_locations_link(start_loc = c("start_x", "start_y"), end_loc = c("end_x", "end_y"))
fc_velocity_polygon(data, metric = "east_west_velocity", shape = "hexagon",
fcn = "median", na.rm = TRUE, size = 6,
preview_grid = TRUE)
fc_velocity_polygon(data, metric = "speed", size = 5, shape = "square",
fcn = "mean", na.rm = TRUE, preview_grid = TRUE)
fc_velocity_polygon(data, metric = "north_south_velocity",
size = 5, shape = "square",
fcn = "median", na.rm = TRUE, preview_grid = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.