Title: | International Cricket Data |
---|---|
Description: | Data on international and other major cricket matches from ESPNCricinfo <https://www.espncricinfo.com> and Cricsheet <https://cricsheet.org>. This package provides some functions to download the data into tibbles ready for analysis. |
Authors: | Rob Hyndman [aut, cre], Charles Gray [aut], Sayani Gupta [aut], Timothy Hyndman [aut], Hassan Rafique [aut], Jacquie Tran [aut], Puwasala Gamakumara [ctb], Alex Whan [ctb] |
Maintainer: | Rob Hyndman <[email protected]> |
License: | GPL-3 |
Version: | 0.2.3 |
Built: | 2024-11-16 04:35:36 UTC |
Source: | https://github.com/robjhyndman/cricketdata |
A dataset containing the names and codes used by cricsheet, as at 28 August 2023.
cricsheet_codes
cricsheet_codes
A data frame with 39 rows and 2 variables.
https://cricsheet.org/downloads/#experimental
Fetch data from ESPNCricinfo and return a tibble. All arguments are case-insensitive and partially matched.
fetch_cricinfo( matchtype = c("test", "odi", "t20"), sex = c("men", "women"), activity = c("batting", "bowling", "fielding"), type = c("career", "innings"), country = NULL )
fetch_cricinfo( matchtype = c("test", "odi", "t20"), sex = c("men", "women"), activity = c("batting", "bowling", "fielding"), type = c("career", "innings"), country = NULL )
matchtype |
Character indicating test (default), odi, or t20. |
sex |
Character indicating men (default) or women. |
activity |
Character indicating batting (default), bowling or fielding. |
type |
Character indicating innings-by-innings or career (default) data |
country |
Character indicating country. The default is to fetch data for all countries. |
A tibble
object, similar to a data.frame
.
Rob J Hyndman, Timothy Hyndman, Charles Gray
## Not run: auswt20 <- fetch_cricinfo("T20", "Women", country = "Aust") IndiaODIBowling <- fetch_cricinfo("ODI", "men", "bowling", country = "india") ## End(Not run)
## Not run: auswt20 <- fetch_cricinfo("T20", "Women", country = "Aust") IndiaODIBowling <- fetch_cricinfo("ODI", "men", "bowling", country = "india") ## End(Not run)
Download csv data from Cricsheet https://cricsheet.org/downloads/.
Data must be specified by three factors:
(a) type of data: bbb
(ball-by-ball), match
or player
.
(b) gender;
(c) competition specified as a Cricsheet code. See cricsheet_codes
for the
competitions and codes available.
fetch_cricsheet( type = c("bbb", "match", "player"), gender = c("female", "male"), competition = "tests" )
fetch_cricsheet( type = c("bbb", "match", "player"), gender = c("female", "male"), competition = "tests" )
type |
Character string giving type of data: ball-by-ball, match info or player info. |
gender |
Character string giving player gender: female or male. |
competition |
Character string giving code corresponding to competition. See |
A tibble
object, similar to a data.frame
.
Jacquie Tran, Hassan Rafique and Rob J Hyndman
## Not run: wbbl_bbb <- fetch_cricsheet(competition = "wbbl", type = "bbb") wbbl_match <- fetch_cricsheet(competition = "wbbl", type = "match") wbbl_player <- fetch_cricsheet(competition = "wbbl", type = "player") ## End(Not run)
## Not run: wbbl_bbb <- fetch_cricsheet(competition = "wbbl", type = "bbb") wbbl_match <- fetch_cricsheet(competition = "wbbl", type = "match") wbbl_player <- fetch_cricsheet(competition = "wbbl", type = "player") ## End(Not run)
Fetch individual player data from all matches played. The function will scrape the data from ESPNCricinfo and return a tibble with one line per innings for all games a player has played. To identify a player, use their Cricinfo player ID. The simplest way to find this is to look up their Cricinfo Profile page. The number at the end of the URL is the ID. For example, Meg Lanning's profile page is http://www.espncricinfo.com/australia/content/player/329336.html, so her ID is 329336.
fetch_player_data( playerid, matchtype = c("test", "odi", "t20"), activity = c("batting", "bowling", "fielding") )
fetch_player_data( playerid, matchtype = c("test", "odi", "t20"), activity = c("batting", "bowling", "fielding") )
playerid |
The player ID as given in the Cricinfo profile. Integer or character. |
matchtype |
Which type of cricket matches do you want? Tests, ODIs or T20s? Not case-sensitive. |
activity |
Which type of activities do you want? Batting, Bowling or Fielding? Not case-sensitive. |
A tibble containing data on the selected player, with one row for every innings of every match in which they have played.
Rob J Hyndman and Sayani Gupta
find_player_id()
to find a player ID by searching on their name,
and fetch_player_meta()
to download meta data for players.
## Not run: # Download data on some players EllysePerry <- fetch_player_data(275487, "T20", "batting") RahulDravid <- fetch_player_data(28114, "ODI", "fielding") LasithMalinga <- fetch_player_data(49758, "Test", "bowling") # Create a plot for Ellyse Perry's T20 scores library(dplyr) library(ggplot2) EllysePerry |> filter(!is.na(Runs)) |> ggplot(aes(x = Start_Date, y = Runs, col = Dismissal, na.rm = TRUE)) + geom_point() + ggtitle("Ellyse Perry's T20 Scores") ## End(Not run)
## Not run: # Download data on some players EllysePerry <- fetch_player_data(275487, "T20", "batting") RahulDravid <- fetch_player_data(28114, "ODI", "fielding") LasithMalinga <- fetch_player_data(49758, "Test", "bowling") # Create a plot for Ellyse Perry's T20 scores library(dplyr) library(ggplot2) EllysePerry |> filter(!is.na(Runs)) |> ggplot(aes(x = Start_Date, y = Runs, col = Dismissal, na.rm = TRUE)) + geom_point() + ggtitle("Ellyse Perry's T20 Scores") ## End(Not run)
Fetch player meta data from ESPNCricinfo and return a tibble with one line per player. To identify the players, use their Cricinfo player IDs. The simplest way to find this is to look up their Cricinfo Profile page. The number at the end of the URL is the ID. For example, Meg Lanning's profile page is http://www.espncricinfo.com/australia/content/player/329336.html, so her ID is 329336.
fetch_player_meta(playerid)
fetch_player_meta(playerid)
playerid |
A vector of player IDs as given in Cricinfo profiles. Integer or character. |
A tibble containing meta data on the selected players, with one row for each player.
Hassan Rafique and Rob J Hyndman
It is usually simpler to just use the saved data set player_meta
which contains the meta data for all players on ESPNCricinfo as at 28 August 2023.
To find a player ID, use find_player_id()
.
Use fetch_player_data()
to download playing statistics for a player.
## Not run: # Download meta data on Meg Lanning and Ellyse Perry aus_women <- fetch_player_meta(c(329336, 275487)) ## End(Not run)
## Not run: # Download meta data on Meg Lanning and Ellyse Perry aus_women <- fetch_player_meta(c(329336, 275487)) ## End(Not run)
Find a player id from cricinfo.com
find_player_id(searchstring)
find_player_id(searchstring)
searchstring |
Part of a player name(s) to search for. Can be a character vector. |
A table of matching players, their ids, and teams they played for.
Rob J Hyndman
fetch_player_data()
to download playing statistics for
a player, and fetch_player_meta()
to download meta data on players.
## Not run: (perry <- find_player_id("Perry")) EllysePerry <- fetch_player_data(perry[2, "ID"], "test") ## End(Not run)
## Not run: (perry <- find_player_id("Perry")) EllysePerry <- fetch_player_data(perry[2, "ID"], "test") ## End(Not run)
A dataset containing the names and other attributes of players who appear on both cricsheet and ESPNCricinfo, as at 28 August 2023.
player_meta
player_meta
A data frame with 14073 rows and 10 variables.
The player_meta data set contains the names and other attributes of players who appear on both cricsheet and ESPNCricinfo as at 28 August 2023. This function returns an updated version of the data set based on information currently available online.
update_player_meta(start_again = FALSE)
update_player_meta(start_again = FALSE)
start_again |
If TRUE, downloads all data from ESPNCricinfo without using player_meta as a starting point. This can take a long time. |
A tibble containing meta data on cricket players.
Hassan Rafique and Rob J Hyndman
player_meta, fetch_player_meta()
.
## Not run: # Update data to current new_player_meta <- update_player_meta() ## End(Not run)
## Not run: # Update data to current new_player_meta <- update_player_meta() ## End(Not run)