##Multi Competition Events Function.
MultiCompEvents <- function(username, password, competitionmatrix, version = "v8",
baseurl = "https://data.statsbomb.com/api/", parallel = TRUE, cores = detectCores()){
events <- tibble()
for(i in 1:dim(competitionmatrix)[1]){
temp.matches <- tibble()
competition_id <- as.numeric(competitionmatrix[i, 1])
season_id <- as.numeric(competitionmatrix[i, 2])
matches <- matchesvector(username, password, season_id, competition_id, version, baseurl)
temp.matches <- allevents(username, password, matches, version, baseurl, parallel, cores)
temp.matches <- temp.matches %>%
mutate(competition_id = competition_id,
season_id = season_id)
events <- bind_rows(events, temp.matches)
}
events <- events %>% dplyr::select(-num_range("shot", 1:20))
return(events)
}
##Pull Competitions From the API
#comps <- competitions(username, password)
##Filter for the competitions you want
#EuropeComps <- comps %>% filter(country_name == "Europe")
##Create a matrix of the competition and season ids
#competitionmatrix <- as.matrix(EuropeComps[,1:2])
##Pull all of the events.
#Events <- MultiCompEvents(username, password, competitionmatrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.