| Title: | Access MLS and NWSL Play-by-Play Data |
|---|---|
| Description: | A utility for working with American soccer data. A scraping and aggregating interface for ESPN's <https://www.espn.com> MLS and NWSL statistics. |
| Authors: | Saiem Gilani [aut, cre] |
| Maintainer: | Saiem Gilani <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-10-12 15:51:16 UTC |
| Source: | https://github.com/sportsdataverse/usfootballR |
This is a thin wrapper on data.table::fread
csv_from_url(...)csv_from_url(...)
... |
passed to data.table::fread |
Get ESPN's MLS game data (play-by-play, team)
espn_mls_game_all(game_id)espn_mls_game_all(game_id)
game_id |
Game ID |
A named list of dataframes: Plays, Team
Saiem Gilani
try(espn_mls_game_all(game_id = 598135))try(espn_mls_game_all(game_id = 598135))
Get ESPN's MLS play by play data
espn_mls_pbp(game_id)espn_mls_pbp(game_id)
game_id |
Game ID |
Returns a play-by-play data frame
Saiem Gilani
try(espn_mls_pbp(game_id = 598135))try(espn_mls_pbp(game_id = 598135))
Get MLS schedule for a specific year/date from ESPN's API
espn_mls_scoreboard(season)espn_mls_scoreboard(season)
season |
Either numeric or character |
Returns a tibble
Saiem Gilani.
# Get schedule from date 2020-08-29 try(espn_mls_scoreboard (season = "20200829"))# Get schedule from date 2020-08-29 try(espn_mls_scoreboard (season = "20200829"))
Get ESPN MLS Standings
espn_mls_standings(year)espn_mls_standings(year)
year |
Either numeric or character (YYYY) |
Returns a tibble
try(espn_mls_standings(year = 2021))try(espn_mls_standings(year = 2021))
Get ESPN's MLS team box data
espn_mls_team_box(game_id)espn_mls_team_box(game_id)
game_id |
Game ID |
Returns a team boxscore data frame
Saiem Gilani
try(espn_mls_team_box(game_id = 598135))try(espn_mls_team_box(game_id = 598135))
Get ESPN's MLS team names and ids
espn_mls_teams()espn_mls_teams()
Returns a tibble
Saiem Gilani
try(espn_mls_teams())try(espn_mls_teams())
Get ESPN's NWSL game data (play-by-play, team)
espn_nwsl_game_all(game_id)espn_nwsl_game_all(game_id)
game_id |
Game ID |
A named list of dataframes: Plays, Team
Saiem Gilani
try(espn_nwsl_game_all(game_id = 601833))try(espn_nwsl_game_all(game_id = 601833))
Get ESPN's NWSL play by play data
espn_nwsl_pbp(game_id)espn_nwsl_pbp(game_id)
game_id |
Game ID |
Returns a play-by-play data frame
Saiem Gilani
try(espn_nwsl_pbp(game_id = 601833))try(espn_nwsl_pbp(game_id = 601833))
Get NWSL schedule for a specific year/date from ESPN's API
espn_nwsl_scoreboard(season)espn_nwsl_scoreboard(season)
season |
Either numeric or character |
Returns a tibble
Saiem Gilani.
# Get schedule from date 2020-08-29 try(espn_nwsl_scoreboard (season = "20200829"))# Get schedule from date 2020-08-29 try(espn_nwsl_scoreboard (season = "20200829"))
Get ESPN NWSL Standings
espn_nwsl_standings(year)espn_nwsl_standings(year)
year |
Either numeric or character (YYYY) |
Returns a tibble
Geoff Hutchinson
try(espn_nwsl_standings(year = 2021))try(espn_nwsl_standings(year = 2021))
Get ESPN's NWSL team box data
espn_nwsl_team_box(game_id)espn_nwsl_team_box(game_id)
game_id |
Game ID |
Returns a team boxscore data frame
Saiem Gilani
try(espn_nwsl_team_box(game_id = 601833))try(espn_nwsl_team_box(game_id = 601833))
Get ESPN's NWSL team names and ids
espn_nwsl_teams()espn_nwsl_teams()
Returns a tibble
Saiem Gilani
try(espn_nwsl_teams())try(espn_nwsl_teams())
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_mls_pbp( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )load_mls_pbp( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given MLS seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the play by play data table within the database |
A dataframe
try(load_mls_pbp(2021))try(load_mls_pbp(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_mls_player_box( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )load_mls_player_box( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given MLS seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the player box data table within the database |
Returns a tibble
try(load_mls_player_box(2021))try(load_mls_player_box(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_mls_schedule( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )load_mls_schedule( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given MLS seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the schedule data table within the database |
Returns a tibble
try(load_mls_schedule(2021))try(load_mls_schedule(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_mls_team_box( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )load_mls_team_box( seasons = most_recent_mls_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given MLS seasons. (Min: 2003) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the team box data table within the database |
Returns a tibble
try(load_mls_team_box(2021))try(load_mls_team_box(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_nwsl_pbp( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )load_nwsl_pbp( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NWSL seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the play by play data table within the database |
A dataframe
try(load_nwsl_pbp(2021))try(load_nwsl_pbp(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_nwsl_player_box( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )load_nwsl_player_box( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NWSL seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the player box data table within the database |
Returns a tibble
try(load_nwsl_player_box(2021))try(load_nwsl_player_box(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_nwsl_schedule( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )load_nwsl_schedule( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NWSL seasons. (Min: 2002) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the schedule data table within the database |
Returns a tibble
try(load_nwsl_schedule(2021))try(load_nwsl_schedule(2021))
helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots
load_nwsl_team_box( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )load_nwsl_team_box( seasons = most_recent_nwsl_season(), ..., dbConnection = NULL, tablename = NULL )
seasons |
A vector of 4-digit years associated with given NWSL seasons. (Min: 2003) |
... |
Additional arguments passed to an underlying function that writes
the season data into a database (used by |
dbConnection |
A |
tablename |
The name of the team box data table within the database |
Returns a tibble
try(load_nwsl_team_box(2021))try(load_nwsl_team_box(2021))
This function helps add progress-reporting to any function - given function f() and progressor p(), it will return a new function that calls f() and then (on-exiting) will call p() after every iteration.
progressively(f, p = NULL)progressively(f, p = NULL)
f |
a function to add progressr functionality to. |
p |
a progressor function as created by |
This is inspired by purrr's safely, quietly, and possibly function decorators.
a function that does the same as f but it calls p() after iteration.
Load .rds file from a remote connection
rds_from_url(url)rds_from_url(url)
url |
a character url |
a dataframe as created by readRDS()
update_mls_db() updates or creates a database with usfootballR
play by play data of all completed and available games since 2002.
update_mls_db( dbdir = ".", dbname = "usfootballR_db", tblname = "usfootballR_mls_pbp", force_rebuild = FALSE, db_connection = NULL )update_mls_db( dbdir = ".", dbname = "usfootballR_db", tblname = "usfootballR_mls_pbp", force_rebuild = FALSE, db_connection = NULL )
dbdir |
Directory in which the database is or shall be located |
dbname |
File name of an existing or desired SQLite database within |
tblname |
The name of the play by play data table within the database |
force_rebuild |
Hybrid parameter (logical or numeric) to rebuild parts of or the complete play by play data table within the database (please see details for further information) |
db_connection |
A |
This function creates and updates a data table with the name tblname
within a SQLite database (other drivers via db_connection) located in
dbdir and named dbname.
The data table combines all play by play data for every available game back
to the 2002 season and adds the most recent completed games as soon as they
are available for usfootballR.
The argument force_rebuild is of hybrid type. It can rebuild the play
by play data table either for the whole usfootballR era (with force_rebuild = TRUE)
or just for specified seasons (e.g. force_rebuild = c(2019, 2020)).
Please note the following behavior:
force_rebuild = TRUE: The data table with the name tblname
will be removed completely and rebuilt from scratch. This is helpful when
new columns are added during the Off-Season.
force_rebuild = c(2019, 2020): The data table with the name tblname
will be preserved and only rows from the 2019 and 2020 seasons will be
deleted and re-added. This is intended to be used for ongoing seasons because
ESPN's data provider can make changes to the underlying data during the week.
The parameter db_connection is intended for advanced users who want
to use other DBI drivers, such as MariaDB, Postgres or odbc. Please note that
the arguments dbdir and dbname are dropped in case a db_connection
is provided but the argument tblname will still be used to write the
data table into the database.
Logical TRUE/FALSE
update_nwsl_db() updates or creates a database with usfootballR
play by play data of all completed and available games since 2002.
update_nwsl_db( dbdir = ".", dbname = "usfootballR_db", tblname = "usfootballR_nwsl_pbp", force_rebuild = FALSE, db_connection = NULL )update_nwsl_db( dbdir = ".", dbname = "usfootballR_db", tblname = "usfootballR_nwsl_pbp", force_rebuild = FALSE, db_connection = NULL )
dbdir |
Directory in which the database is or shall be located |
dbname |
File name of an existing or desired SQLite database within |
tblname |
The name of the play by play data table within the database |
force_rebuild |
Hybrid parameter (logical or numeric) to rebuild parts of or the complete play by play data table within the database (please see details for further information) |
db_connection |
A |
This function creates and updates a data table with the name tblname
within a SQLite database (other drivers via db_connection) located in
dbdir and named dbname.
The data table combines all play by play data for every available game back
to the 2002 season and adds the most recent completed games as soon as they
are available for usfootballR.
The argument force_rebuild is of hybrid type. It can rebuild the play
by play data table either for the whole usfootballR era (with force_rebuild = TRUE)
or just for specified seasons (e.g. force_rebuild = c(2019, 2020)).
Please note the following behavior:
force_rebuild = TRUE: The data table with the name tblname
will be removed completely and rebuilt from scratch. This is helpful when
new columns are added during the Off-Season.
force_rebuild = c(2019, 2020): The data table with the name tblname
will be preserved and only rows from the 2019 and 2020 seasons will be
deleted and re-added. This is intended to be used for ongoing seasons because
ESPN's data provider can make changes to the underlying data during the week.
The parameter db_connection is intended for advanced users who want
to use other DBI drivers, such as MariaDB, Postgres or odbc. Please note that
the arguments dbdir and dbname are dropped in case a db_connection
is provided but the argument tblname will still be used to write the
data table into the database.
Logical TRUE/FALSE