### Get Match Summary Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_summary.html Demonstrates how to retrieve match summary data using the get_match_summary function. It first obtains a match URL and then calls the function to get the events for that match. This example is wrapped in a try-catch block for error handling. ```r if (FALSE) { try({ match <- get_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- get_match_summary(match_url = match) }) } ``` -------------------------------- ### Get Advanced Match Stats Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_advanced_match_stats.html This example demonstrates how to fetch possession statistics for individual players from Australian Women's A-League matches. It first retrieves match URLs and then uses get_advanced_match_stats to get the data. Ensure you have the necessary functions like get_match_urls available. ```R if (FALSE) { try({ urls <- get_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st") df <- get_advanced_match_stats(match_url=urls,stat_type="possession",team_or_player="player") }) } ``` -------------------------------- ### Get Match Lineups Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_lineups.html Fetches the match lineups for a given FBref.com match URL. It's recommended to wrap this in a try-catch block to handle potential errors during data retrieval. The example first obtains a match URL using get_match_urls. ```R if (FALSE) { try({ match <- get_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- get_match_lineups(match_url = match) }) } ``` -------------------------------- ### Get Match Report Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_report.html Demonstrates how to retrieve a match report using the get_match_report function. It first obtains a match URL and then calls the function to get the report details. This example is wrapped in a try-catch block for error handling and is conditional to prevent execution on CRAN. ```r if (FALSE) { try({ match <- get_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- get_match_report(match_url = match) }) } ``` -------------------------------- ### Example: Extracting Match Lineups Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_match_lineups.html This example shows how to first get a match URL for a specific competition and season, and then use that URL with the fb_match_lineups function to obtain the team lineups. It includes error handling with a try-catch block. ```R if (FALSE) { try({ match <- fb_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- fb_match_lineups(match_url = match) }) } ``` -------------------------------- ### Get Non-Domestic League Match URLs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_urls.html This example shows how to get match URLs for a non-domestic league (e.g., Friendlies) by providing the specific FBref URL for that competition. The `country` argument is left blank as it's not applicable for non-domestic leagues. ```R if (FALSE) { non_dom <- "https://fbref.com/en/comps/218/history/Friendlies-M-Seasons" get_match_urls(country = "", gender = "M", season_end_year = 2021, non_dom_league_url = non_dom) }) ``` -------------------------------- ### Get Match Info by Match IDs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fotmob_get_match_info.html Retrieves detailed match information from fotmob.com. Requires the `dplyr` and `tidyr` packages. This example first fetches matches by date, filters for Premier League matches in England, extracts their IDs, and then uses `fotmob_get_match_info` to get the details for those specific matches. ```r # \donttest{ try({ library(dplyr) library(tidyr) results <- fotmob_get_matches_by_date(date = "20210926") match_ids <- results %>% dplyr::select(primary_id, ccode, league_name = name, match_id) %>% dplyr::filter(league_name == "Premier League", ccode == "ENG") %>% dplyr::pull(match_id) match_ids # 3609987 3609979 details <- fotmob_get_match_info(match_ids) }) # } ``` -------------------------------- ### Get Match Shooting Data Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_shooting.html Demonstrates how to use the get_match_shooting function to retrieve shooting data for a specific match. It includes error handling and specifies the match URL and a time pause. ```r if (FALSE) { try({ match <- "https://fbref.com/en/matches/bf52349b/Fulham-Arsenal-September-12-2020-Premier-League" df <- get_match_shooting(match_url = match) }) } ``` -------------------------------- ### Get Single Player Goal Logs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_player_goal_logs.html Fetches the goal logs for a single player from FBref. Ensure the player URL is correctly specified. This example is wrapped in a try-catch block for error handling. ```r if (FALSE) { try({ # for single players: jwp_url <- "https://fbref.com/en/players/3515d404/" fb_player_goal_logs(player_urls = jwp_url, goals_or_assists = "goals") }) } ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/CONTRIBUTING.html Installs all necessary development dependencies for the package. ```r devtools::install_dev_deps() ``` -------------------------------- ### Get Playing Time Stats for Multiple Teams Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_team_player_stats.html Retrieves playing time statistics for multiple teams within a league. This example first gets league URLs, then team URLs, and finally fetches the 'playing_time' stats for those teams. It's wrapped in a try-catch block to handle potential errors during data retrieval. ```r league_url <- fb_league_urls(country = "ENG", gender = "M", season_end_year = 2022, tier = "3rd") team_urls <- fb_teams_urls(league_url) multiple_playing_time <- fb_team_player_stats(team_urls, stat_type = "playing_time") ``` -------------------------------- ### Load worldfootballR library Source: https://github.com/jaseziv/worldfootballr/blob/main/README.md Load the worldfootballR package into your R session after installation to start using its functions. ```r library(worldfootballR) ``` -------------------------------- ### Install worldfootballR Package Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-helper-urls.html Install the worldfootballR package from GitHub using the devtools package. Ensure devtools is installed first. ```r # install.packages("devtools") devtools::install_github("JaseZiv/worldfootballR") library(worldfootballR) library(dplyr) ``` -------------------------------- ### Get Fotmob Match Details by Match ID Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fotmob_get_match_details.html Retrieves match details for specified match IDs. Requires the `dplyr` and `tidyr` packages. This example first fetches matches by date, filters for Premier League matches in England, extracts their IDs, and then retrieves the details for those matches. ```R # \donttest{ try({ library(dplyr) library(tidyr) results <- fotmob_get_matches_by_date(date = "20210926") match_ids <- results %>% dplyr::select(primary_id, ccode, league_name = name, match_id) %>% dplyr::filter(league_name == "Premier League", ccode == "ENG") %>% dplyr::pull(match_id) match_ids # 3609987 3609979 details <- fotmob_get_match_details(match_ids) }) # } ``` -------------------------------- ### Install Latest worldfootballR Version Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/ISSUE_TEMPLATE.html Use this command to install the most recent version of the worldfootballR package from GitHub. Restart your R session after installation. ```r remotes::install_github("JaseZiv/worldfootballR") ``` -------------------------------- ### Install worldfootballR from CRAN Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Install the stable version of the worldfootballR package from CRAN. ```r install.packages("worldfootballR") ``` -------------------------------- ### Get FBref Match Report Function Usage Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_match_report.html Demonstrates how to use the `fb_match_report` function to retrieve match details. It requires a match URL and optionally accepts a time pause argument. The example shows fetching data for a specific Australian Women's League match. ```r if (FALSE) { try({ match <- fb_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- fb_match_report(match_url = match) }) } ``` -------------------------------- ### Get League Table using League URL Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-season-data.html Retrieve a league table by providing the specific transfermarkt league URL, season start year, and matchday. This is useful for leagues not automatically recognized by country name. ```R league_one_matchday_1_table <- tm_matchday_table(start_year="2020", matchday=1, league_url="https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3") ``` -------------------------------- ### Get Team Goal Logs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fbref-data.html Retrieves goal logs for a team, specifying whether to get goals 'for', 'against', or 'both'. Requires a team URL and the 'for_or_against' parameter. ```R man_city_url <- "https://fbref.com/en/squads/b8fd03ef/Manchester-City-Stats" g oal_log <- function(team_urls = man_city_url, for_or_against="both") dplyr::glimpse(goal_log) ``` -------------------------------- ### Get fbref League URLs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_league_urls.html Returns the URLs for season leagues of a selected country. ```APIDOC ## fb_league_urls ### Description Returns the URLs for season leagues of a selected country. ### Usage fb_league_urls(country, gender, season_end_year, tier = "1st") ### Arguments * **country** (character) - the three character country code * **gender** (character) - gender of competition, either "M" or "F" * **season_end_year** (numeric) - the year the season(s) concludes (defaults to all available seasons) * **tier** (character) - the tier of the league, ie '1st' for the EPL or '2nd' for the Championship and so on ### Value returns a character vector of all fbref league URLs for selected country, season, gender and tier ### Examples if (FALSE) { try({ fb_league_urls(country = "ENG", gender = "M", season_end_year = 2021, tier = '1st') }) } ``` -------------------------------- ### Get FBref match team stats Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_team_match_stats.html Returns match team stats for selected matches from FBref.com. ```APIDOC ## fb_team_match_stats ### Description Returns match team stats for selected matches. ### Usage fb_team_match_stats(match_url, time_pause = 3) ### Arguments * **match_url** (character) - The fbref.com URL for the required match. * **time_pause** (numeric) - The wait time (in seconds) between page loads. Defaults to 3 seconds. ### Value Returns a dataframe with the match team stats for a selected match. ### Examples ```R if (FALSE) { try({ match <- fb_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- fb_team_match_stats(match_url = match) }) } ``` ``` -------------------------------- ### Comparison with fotmob_get_match_details Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fotmob_match_details.html This example shows that the output format of `load_fotmob_match_details` for a single league is the same as the output from `fotmob_get_match_details` when provided with a specific match ID. ```r fotmob_get_match_details(match_id = 3411352) ``` -------------------------------- ### Load worldfootballR and data manipulation libraries Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Load the worldfootballR package along with dplyr and tidyr for data manipulation after installation. ```r library(worldfootballR) library(dplyr) library(tidyr) ``` -------------------------------- ### Load Match IDs for Multiple Leagues Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fotmob_matches_by_date.html This example demonstrates how to load match IDs for multiple leagues simultaneously by providing vectors for country and league names. The lengths of these vectors must match. ```r load_fotmob_matches_by_date( country = c("ENG", "ESP" ), league_name = c("Premier League", "LaLiga") ) ``` -------------------------------- ### Get Team Season Stats Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Retrieve season statistics for a specific team in a given league and season. Note: This example is commented out to avoid potential errors. ```r fotmob_get_season_stats( league_id = 47, season_name = "2020/2021", stat_name = "Expected goals", team_or_player = "team", stat_league_name = "FA Cup" ) ``` -------------------------------- ### Retrieve Defense Stats for Italian League Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_season_team_stats.html Example of how to call the fb_season_team_stats function to get defense statistics for the Italian Serie A in the 2021 season. It includes error handling with tryCatch. ```r if (FALSE) { try({ fb_season_team_stats("ITA", "M", 2021, "1st", "defense") }) } ``` -------------------------------- ### Get League Table by Matchday Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Use tm_matchday_table() to extract league tables for specific matchdays. Can use country name and season start year, or a league URL for custom leagues. ```R #----- to get the EPL table after matchday 1 of the 20/21 season: ----- epl_matchday_1_table <- tm_matchday_table(country_name="England", start_year="2020", matchday=1) dplyr::glimpse(epl_matchday_1_table) ``` ```R #----- to get the League One table after each matchdays from matchday 1 to matchday 5 of the 20/21 season: ----- league_one_matchday_1_table <- tm_matchday_table(start_year="2020", matchday=1:5, league_url="https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3") dplyr::glimpse(league_one_matchday_1_table) ``` -------------------------------- ### Get single team player wages Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_squad_wages.html Example of how to retrieve player wages for a single team using the `fb_squad_wages` function. Ensure you have error handling in place, especially when dealing with web scraping. ```r if (FALSE) { try({ # for single teams: man_city_url <- "https://fbref.com/en/squads/b8fd03ef/Manchester-City-Stats" fb_squad_wages(team_urls = man_city_url) }) } ``` -------------------------------- ### Load Fotmob Match Details for Multiple Leagues Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fotmob_match_details.html Illustrates loading match details for multiple leagues simultaneously by providing vectors of country and league names. This is useful for comparative analysis across different leagues. ```r load_fotmob_match_details( country = c("ENG", "ESP" ), league_name = c("Premier League", "LaLiga") ) ``` -------------------------------- ### Load Fotmob Match Details for One League Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fotmob_match_details.html Demonstrates how to load match details for a single league by specifying the country and league name. This is the primary way to use the function for a specific league. ```r load_fotmob_match_details( country = "ENG", league_name = "Premier League" ) ``` -------------------------------- ### Get Player Absences Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/tm_get_player_absence.html Retrieves a dataframe of player absences from suspension for the provided player URLs. This example demonstrates how to use the function with multiple player URLs and includes error handling with a try-catch block. ```r if (FALSE) { try({ player_urls <- c("https://www.transfermarkt.com/cristian-romero/profil/spieler/355915", "https://www.transfermarkt.com/micky-van-de-ven/profil/spieler/557459") df <- tm_get_player_absence(player_urls) }) } ``` -------------------------------- ### Load Understat League Shots Example Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_understat_league_shots.html Demonstrates how to load shot locations for the 'Serie A' league using the `load_understat_league_shots` function. It is wrapped in a try-catch block to handle potential errors during data loading. ```r if (FALSE) { try({ df <- load_understat_league_shots(league = "Serie A") }) } ``` -------------------------------- ### Get Passing Stats for a Single Team Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_team_match_log_stats.html Retrieves passing statistics for a specific team in a season. Ensure the team URL and stat_type are correctly specified. This example is wrapped in a try-catch block for error handling. ```r if (FALSE) { try({ # for single teams: man_city_url <- "https://fbref.com/en/squads/b8fd03ef/Manchester-City-Stats" fb_team_match_log_stats(team_urls = man_city_url, stat_type = "passing") }) } ``` -------------------------------- ### Example of Multiple Parameters for fb_league_stats Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fbref-data.html Demonstrates how to pass multiple values for country, gender, season_end_year, and tier to the fb_league_stats function. Note that stat_type and team_or_player must remain single values. ```r # fb_league_stats( # country = c("ENG", "ESP") # gender = c("M", "F") # season_end_year = 2020:2021, # tier = c("1st", "2nd"), # non_dom_league_url = NA, # stat_type = "shooting", # team_or_player = "player" # ) ``` -------------------------------- ### Get Team Transfer Balances Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/tm_team_transfer_balances.html Retrieves aggregated team transfer performances for a chosen league season. Specify the country name and the start year of the season. An optional league URL can be provided if the country name is not sufficient. ```R tm_team_transfer_balances(country_name = "England", start_year = 2021) ``` -------------------------------- ### Get FBref Team Match Results for a Single Team Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_team_match_results.html Demonstrates how to fetch match results for a specific team by providing its FBref squad URL. It's recommended to wrap this in a try-catch block to handle potential errors. ```r if (FALSE) { try({ # for single teams: man_city_url <- "https://fbref.com/en/squads/b8fd03ef/Manchester-City-Stats" fb_team_match_results(man_city_url) }) } ``` -------------------------------- ### Get Team Stats Using League ID Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Retrieves team statistics for a specific league using its ID, bypassing the need for country and league name. This example fetches expected goals for Premier League (ID 47) in the 2020/2021 season. ```r fotmob_get_season_stats( league_id = 47, season_name = "2020/2021", stat_name = "Expected goals", team_or_player = "team" ) ``` -------------------------------- ### Create GitHub Fork and Clone Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/CONTRIBUTING.html Use this function to fork the package repository and clone it to your local machine. ```r usethis::create_from_github("JaseZiv/worldfootballR", fork = TRUE) ``` -------------------------------- ### Get Player Goal and Assist Logs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fbref-data.html Retrieves logs of goals, assists, or both for a specific player. Requires the player's FBref URL and the 'goals_or_assists' parameter, which can be set to 'goals', 'assists', or 'both'. ```R jwp_url <- "https://fbref.com/en/players/3515d404/James-Ward-Prowse" goal_log <- fb_player_goal_logs(jwp_url, goals_or_assists="both") dplyr::glimpse(goal_log) ``` -------------------------------- ### Load FBref Advanced Match Stats (Multiple Countries/Defense Stats) Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fb_advanced_match_stats.html Loads advanced defensive player statistics for multiple countries and a specific season end year. This example demonstrates how to specify multiple countries and a particular stat type. ```R load_fb_advanced_match_stats( country = c("ITA", "ESP"), gender = "M", tier = "1st", season_end_year = 2023, stat_type = "defense", team_or_player = "player" ) }) #> → Data not loaded. Please check parameters. #> → Data not loaded. Please check parameters. #> data frame with 0 columns and 0 rows # } ``` -------------------------------- ### Get English Men's 1st Tier Match URLs for Multiple Seasons Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_urls.html Use this snippet to retrieve all FBref match URLs for the English men's 1st tier league for seasons ending in 2019, 2020, and 2021. Ensure the worldfootballR package is installed and loaded. ```R if (FALSE) { try({ get_match_urls(country = "ENG", gender = "M", season_end_year = c(2019:2021), tier = "1st") }) } ``` -------------------------------- ### Get Defense Stats for Italian Men's 1st Division Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_season_team_stats.html Example of how to retrieve 'defense' statistics for the Italian men's top league for the 2021 season. This function requires country code, gender, season end year, league tier, and the desired stat type. ```R if (FALSE) { try({ get_season_team_stats("ITA", "M", 2021, "1st", "defense") }) } ``` -------------------------------- ### Get League Matches and Unnest Data Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Fetch matches for multiple leagues (English Premier League and LaLiga) and then unnest the home and away team details for easier analysis. ```r league_matches <- fotmob_get_league_matches( country = c("ENG", "ESP" ), league_name = c("Premier League", "LaLiga") ) league_matches_unnested <- league_matches %>% dplyr::select(match_id = id, home, away) %>% tidyr::unnest_wider(c(home, away), names_sep = "_") dplyr::glimpse(league_matches_unnested) ``` -------------------------------- ### Get Non-Domestic League Player Standard Stats Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_league_stats.html Fetches standard statistics for players in a non-domestic league (e.g., Champions League) for the 2023 season. This example uses a specific URL for the competition and is noted as more likely to fail due to the large volume of players. It's recommended to use 'try' for error handling. ```R ## Non-domestic league ## Note that this is more likely to fail due to the volume of players fb_league_stats( country = NA_character_, gender = "M", season_end_year = 2023, tier = NA_character_, non_dom_league_url = "https://fbref.com/en/comps/8/history/Champions-League-Seasons", stat_type = "standard", team_or_player = "player" ) }) ``` -------------------------------- ### load_match_comp_results Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_match_comp_results.html Returns the game results for a competition(s), ie League cups or international competitions from FBref. comp_name comes from https://github.com/JaseZiv/worldfootballR_data/tree/master/data/match_results_cups#readme ```APIDOC ## load_match_comp_results ### Description Returns the game results for a competition(s), ie League cups or international competitions from FBref. The `comp_name` parameter should be one of the names found at https://github.com/JaseZiv/worldfootballR_data/tree/master/data/match_results_cups#readme. ### Usage ```R load_match_comp_results(comp_name) ``` ### Arguments * **comp_name** (character or character vector) - The name(s) of the competition(s) to load results for. ### Value A dataframe containing the results of the specified competition(s). ### Examples ```R # Load results for a single competition try({ df <- load_match_comp_results(comp_name = "Coppa Italia") }) # Load results for multiple competitions cups <- c("FIFA Women's World Cup", "FIFA World Cup") try({ df <- load_match_comp_results(comp_name = cups) }) ``` ``` -------------------------------- ### Get Match Lineups Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-match-data.html Retrieves a dataframe of all players for a match, indicating starters and bench players. Includes summary performance data for players who participated. ```R # function to extract match lineups liv_mci_2020_lineups <- get_match_lineups(match_url = "https://fbref.com/en/matches/47880eb7/Liverpool-Manchester-City-November-10-2019-Premier-League") ``` -------------------------------- ### get_match_lineups Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/get_match_lineups.html Returns lineups for home and away teams for a selected match from FBref.com. ```APIDOC ## get_match_lineups ### Description Returns lineups for home and away teams for a selected match. ### Usage ```R get_match_lineups(match_url, time_pause = 3) ``` ### Arguments * `match_url` (character) - the fbref.com URL for the required match * `time_pause` (numeric) - the wait time (in seconds) between page loads ### Value A dataframe with the team lineups for a selected match. ### Examples ```R if (FALSE) { try({ match <- get_match_urls(country = "AUS", gender = "F", season_end_year = 2021, tier = "1st")[1] df <- get_match_lineups(match_url = match) }) } ``` ``` -------------------------------- ### Get League Debutants Function Signature Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/tm_league_debutants.html This is the function signature for `tm_league_debutants`. It outlines the required and optional arguments for retrieving league debutant data. ```R tm_league_debutants( country_name, league_url = NA, debut_type, debut_start_year, debut_end_year ) ``` -------------------------------- ### Get Match Team Stats Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Retrieves team-level statistics for a given set of FotMob matches. Use this to get detailed stats like possession, xG, and shots. ```r match_team_stats <- fotmob_get_match_team_stats(fotmob_matches) match_team_stats %>% dplyr::select(match_id, title:dplyr::last_col()) %>% dplyr::glimpse() #> Rows: 92 #> Columns: 7 #> $ match_id 3609994, 3609994, 3609994, 3609994, 3609994, 3609994… #> $ title "Top stats", "Top stats", "Top stats", "Top stats", … #> $ stats_title "Ball possession", "Expected goals (xG)", "Total sho… #> $ home_value "48", "0.78", "6", "3", "1", "423 (84%)", "10", "2",… #> $ away_value "52", "1.66", "12", "1", "1", "443 (84%)", "12", "5"… #> $ stats_type "graph", "text", "text", "text", "text", "text", "te… #> $ stats_highlighted "away", "away", "away", "home", "equal", "away", "ho… ``` -------------------------------- ### Get Match Details and Shooting Locations Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fotmob-data.html Use `fotmob_get_match_details()` to fetch detailed information for matches, including shooting events and their associated metrics like xG. The output provides a comprehensive view of match events. ```r match_details <- fotmob_get_match_details(fotmob_matches) dplyr::glimpse(match_details) ``` -------------------------------- ### Get Player Market Valuations for a Single Team Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Use tm_each_team_player_market_val to get player market valuations for a specific team. Requires the team's Transfermarkt URL. ```R rma <- "https://www.transfermarkt.com/real-madrid/startseite/verein/418/saison_id/2024" rma_vals <- tm_each_team_player_market_val(each_team_url = rma) ``` -------------------------------- ### Get Player Information Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fbref-data.html Fetches basic information for one or more players using their FBref URLs. Requires a vector of player URLs. ```R player_urls <- c( "https://fbref.com/en/players/d70ce98e/", # Messi "https://fbref.com/en/players/3515d404/" # JWP ) messi_and_jwp_info <- fb_player_info(player_urls) dplyr::glimpse(messi_and_jwp_info) ``` -------------------------------- ### Get League Risk of Suspension by Country Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/tm_get_risk_of_suspension.html Use this function to get a data frame of players at risk of suspension for a given country's league. Ensure the country name is valid. ```R tm_get_risk_of_suspension(country_name = "England") ``` -------------------------------- ### Basic Issue Reporting Template Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/ISSUE_TEMPLATE.html A template for reporting issues, including loading the library, checking the package version, inserting your code, and capturing session information. ```r library(worldfootballR) packageVersion("worldfootballR") # insert code here sessionInfo() ``` -------------------------------- ### Get Player Absence History (Multiple Players) Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Retrieves absence history for multiple players. Use a helper function like `tm_team_player_urls` to get a list of player URLs first. ```r # can make use of a tm helper function: spurs_player_urls <- tm_team_player_urls(team_url = "https://www.transfermarkt.com/tottenham-hotspur/startseite/verein/148") # then pass all those URLs to the tm_get_player_absence spurs_player_absence <- tm_get_player_absence(player_urls = spurs_player_urls) ``` -------------------------------- ### Get League Debutants Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Use tm_league_debutants() to find players making league or professional debuts within a specified year range. Specify debut_type as 'league' or 'pro'. ```R # Laliga players making their LaLiga debut in 2021/2022 laliga_debutants <- tm_league_debutants(country_name = "Spain", debut_type = "league", debut_start_year = 2021, debut_end_year = 2021) dplyr::glimpse(laliga_debutants) ``` ```R # English League One players making their PRO debuts in 2021/2022 league_one_PRO_debutants <- tm_league_debutants(country_name = "", league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3", debut_type = "pro", debut_start_year = 2021, debut_end_year = 2021) dplyr::glimpse(league_one_PRO_debutants) ``` -------------------------------- ### fotmob_get_league_tables Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fotmob_get_league_tables.html Returns league standings from fotmob.com. It can return all standings, or standings for home or away matches only. ```APIDOC ## Function: fotmob_get_league_tables ### Description Returns league standings from fotmob.com. Three types of standings are returned: all, home, and away. ### Usage fotmob_get_league_tables(country, league_name, league_id, cached = TRUE) ### Arguments * **country** (string or vector of strings) - Three character country code. Can be one or multiple. If provided, `league_name` must also be provided (of the same length). * **league_name** (string or vector of strings) - League names. If provided, `country` must also be provided (of the same length). * **league_id** (numeric or vector of numerics) - Fotmob ID for the league. Only used if `country` and `league_name` are not specified. * **cached** (boolean) - Whether to load the dataframe from the pre-saved CSV file. Defaults to TRUE. ### Value Returns a dataframe of league standings. ### Examples ```R # Load necessary libraries library(dplyr) library(tidyr) # Get standings for a single league by country and name league_tables_single <- fotmob_get_league_tables( country = "ENG", league_name = "Premier League" ) # Get standings for a single league by its ID league_tables_id <- fotmob_get_league_tables( league_id = 47 ) # Get standings for multiple leagues league_tables_multiple <- fotmob_get_league_tables( country = c("ENG", "ESP"), league_name = c("Premier League", "LaLiga") ) # Filter for away match standings away_standings <- league_tables_multiple %>% dplyr::filter(table_type == "away") ``` ``` -------------------------------- ### Get Multiple Team Match Results Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/team-and-player-data.html Fetches all game results for multiple teams in a league for a season. First, get all team URLs for the league using fb_teams_urls, then pass them to get_team_match_results. ```r epl_2021_team_urls <- fb_teams_urls("https://fbref.com/en/comps/9/Premier-League-Stats") epl_2021_team_results <- get_team_match_results(team_url = team_urls) ``` -------------------------------- ### tm_team_transfers() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get team transfers. ```APIDOC ## tm_team_transfers() ### Description Get team transfers. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### fotmob_get_match_info Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fotmob_get_match_info.html Returns match info from fotmob.com by providing a vector of match IDs. ```APIDOC ## fotmob_get_match_info ### Description Returns match info from fotmob.com. ### Usage ```R fotmob_get_match_info(match_ids) ``` ### Arguments * **match_ids** (vector of strings or numbers) - A vector representing matches. ### Value Returns a dataframe of match info. ### Examples ```R # Example of how to use fotmob_get_match_info library(dplyr) library(tidyr) results <- fotmob_get_matches_by_date(date = "20210926") match_ids <- results %>% dplyr::select(primary_id, ccode, league_name = name, match_id) %>% dplyr::filter(league_name == "Premier League", ccode == "ENG") %>% dplyr::pull(match_id) match_ids # Returns: 3609987 3609979 details <- fotmob_get_match_info(match_ids) ``` ``` -------------------------------- ### Load FBref Advanced Match Stats (Player Summary) Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fb_advanced_match_stats.html Loads advanced player statistics for a specified country, gender, and league tier. Ensure parameters are correctly set to avoid data loading errors. ```R # \donttest{ try({ load_fb_advanced_match_stats( country = "ENG", gender = "M", tier = "1st", stat_type = "summary", team_or_player = "player" ) ``` -------------------------------- ### Get Staff URLs for a Team and Role Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Use tm_team_staff_urls() to get staff URLs for specified team URLs and staff roles like 'Manager' or 'Goalkeeping Coach'. Requires prior retrieval of team URLs. ```R # get a list of team URLs for the EPL 2021/22 season epl_teams <- tm_league_team_urls(country_name = "England", start_year = 2021) # get all EPL managers for the 2021/22 season epl_managers <- tm_team_staff_urls(team_urls = epl_teams, staff_role = "Manager") # get all EPL goal keeping coaches for the 2021/22 season epl_gk_coaches <- tm_team_staff_urls(team_urls = epl_teams, staff_role = "Goalkeeping Coach") ``` -------------------------------- ### Get Player Transfer History (Multiple Players, No Extra Info) Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-transfermarkt-data.html Extracts transfer histories for multiple players from a list of URLs, without extra transfer details. First, get player URLs using `tm_team_player_urls`. ```r all_leeds_united_links <- tm_team_player_urls(team_url = "https://www.transfermarkt.com/leeds-united/startseite/verein/399") all_leeds_united_players_transfer_history <- tm_player_transfer_history(all_leeds_united_links, get_extra_info = FALSE) dplyr::glimpse(all_leeds_united_players_transfer_history) ``` -------------------------------- ### understat_team_meta() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get Understat team info. ```APIDOC ## understat_team_meta() ### Description Get Understat team info. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### understat_available_teams() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get Understat available teams. ```APIDOC ## understat_available_teams() ### Description Get Understat available teams. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### get_player_market_values() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get player market values. ```APIDOC ## get_player_market_values() ### Description Get player market values. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### load_fotmob_match_details Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/load_fotmob_match_details.html Loads pre-saved Fotmob match details for specified leagues. This function is a loading version of `fotmob_get_match_details` that can retrieve data for multiple seasons, going back to the 2020-21 season for most leagues. ```APIDOC ## load_fotmob_match_details ### Description Loads pre-saved Fotmob match details for specified leagues. This function is a loading version of `fotmob_get_match_details` that can retrieve data for multiple seasons, going back to the 2020-21 season for most leagues. ### Usage ```R load_fotmob_match_details(country, league_name, league_id, cached = TRUE) ``` ### Arguments * **country** (string or vector of strings) - Three character country code. Can be one or multiple. If provided, `league_name` must also be provided (of the same length). * **league_name** (string or vector of strings) - League names. If provided, `country` must also be provided (of the same length). * **league_id** (numeric or vector of numerics) - Fotmob ID for the league. Only used if `country` and `league_name` are not specified. * **cached** (boolean) - Whether to load the dataframe from the [data CSV](https://github.com/JaseZiv/worldfootballR_data/blob/master/raw-data/fotmob-leagues/all_leagues.csv). Defaults to TRUE. ### Value A dataframe of league matches. ### Examples ```R if (FALSE) { try({ # one league load_fotmob_match_details( country = "ENG", league_name = "Premier League" ) ## this is the same output format as the following fotmob_get_match_details(match_id = 3411352) # one league, by id load_fotmob_match_details(league_id = 47) # multiple leagues (could also use ids) load_fotmob_match_details( country = c("ENG", "ESP" ), league_name = c("Premier League", "LaLiga") ) }) } ``` ``` -------------------------------- ### tm_league_debutants Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/tm_league_debutants.html Retrieves a data frame of debutants for a selected league from Transfermarkt. You can specify the country, debut type (league or professional), and the desired year range for the debut seasons. ```APIDOC ## tm_league_debutants ### Description Returns a data frame of debutants for a selected league. ### Usage ```R tm_league_debutants( country_name, league_url = NA, debut_type, debut_start_year, debut_end_year ) ``` ### Arguments * **country_name** (string) - The country of the league's players. * **league_url** (string, optional) - League URL from transfermarkt.com. To be used when country_name is not available in the main function. * **debut_type** (string) - Whether you want 'league' debut or 'pro' debut. * **debut_start_year** (integer) - The season start year of the beginning of the period you want results for. * **debut_end_year** (integer) - The season start year of the end of the period you want results for. ### Value Returns a dataframe of players who debuted in the selected league. ``` -------------------------------- ### tm_team_staff_history() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get team staff history. ```APIDOC ## tm_team_staff_history() ### Description Get team staff history. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### Load FBref Match Summary Data Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/load-scraped-data.html Use `load_fb_match_summary()` to load pre-scraped match summaries. Specify country, gender, and tier. Optionally, filter by `season_end_year` to load data for a specific season. ```r epl_match_summary <- load_fb_match_summary( country = "ENG", gender = "M", tier = "1st" ) dplyr::glimpse(epl_match_summary) ``` ```r multiple_match_summary_2019 <- load_fb_match_summary( country = c("ITA", "FRA"), gender = "M", tier = "1st", season_end_year = 2019 ) dplyr::glimpse(multiple_match_summary_2019) ``` -------------------------------- ### tm_team_player_urls() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get transfermarkt Player URLs. ```APIDOC ## tm_team_player_urls() ### Description Get transfermarkt Player URLs. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### understat_team_stats_breakdown() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get Understat team statistics breakdowns. ```APIDOC ## understat_team_stats_breakdown() ### Description Get Understat team statistics breakdowns. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### Get FBref Player Match Logs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/fb_player_match_logs.html Retrieves all match logs for a selected player, season, and stat type from FBref. Ensure you handle potential HTTP 403 errors. ```r # \donttest{ try({ fb_player_match_logs("https://fbref.com/en/players/3bb7b8b4/Ederson", season_end_year = 2021, stat_type = 'summary') }) # } ``` -------------------------------- ### Get Match URLs Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/articles/extract-fbref-data.html Generates a list of match URLs for a given country, gender, season, and league tier. Essential for accessing detailed match-level data. ```R epl_2021_urls <- fb_match_urls(country = "ENG", gender = "M", season_end_year = 2021, tier="1st") ``` -------------------------------- ### understat_team_players_stats() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get Understat team player stats. ```APIDOC ## understat_team_players_stats() ### Description Get Understat team player stats. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### Load FotMob Match Details Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/news/index.html Function to load pre-stored match details from FotMob. ```r load_fotmob_match_details() ``` -------------------------------- ### understat_player_shots() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get all Understat shot locations for a player. ```APIDOC ## understat_player_shots() ### Description Get all Understat shot locations for a player. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ``` -------------------------------- ### understat_match_shots() Source: https://github.com/jaseziv/worldfootballr/blob/main/docs/reference/index.html Get Understat match shot locations. ```APIDOC ## understat_match_shots() ### Description Get Understat match shot locations. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ```