Learn R Programming

cricketr (version 0.0.13)

getPlayerDataTT: Get the Twenty20 International player data from ESPN Cricinfo based on specific inputs and store in a file in a given directory~

Description

Get the Twenty20 player data given the profile of the batsman/bowler. The allowed inputs are home,away, neutralboth and won,lost,tied or no result of matches. The data is stored in a .csv file in a directory specified. This function also returns a data frame of the player

Usage

getPlayerDataTT(profile, dir = "./data", file = "player001.csv", type = "batting", homeOrAway = c(1, 2, 3), result = c(1, 2, 3,5))

Arguments

profile
This is the profile number of the player to get data. This can be obtained from http://www.espncricinfo.com/ci/content/player/index.html. Type the name of the player and click search. This will display the details of the player. Make a note of the profile ID. For e.g For Virat Kohli this turns out to be 253802 http://www.espncricinfo.com/india/content/player/35263.html. Hence the profile for Sehwag is 35263
dir
Name of the directory to store the player data into. If not specified the data is stored in a default directory "./data". Default="./data"
file
Name of the file to store the data into for e.g. kohli.csv. This can be used for subsequent functions. Default="player001.csv"
type
type of data required. This can be "batting" or "bowling"
homeOrAway
This is vector with either or all 1,2, 3. 1 is for home 2 is for away, 3 is for neutral venue
result
This is a vector that can take values 1,2,3,5. 1 - won match 2- lost match 3-tied 5- no result

Value

Returns the player's dataframe

Details

More details can be found in my short video tutorial in Youtube https://www.youtube.com/watch?v=q9uMPFVsXsI

References

http://www.espncricinfo.com/ci/content/stats/index.html https://gigadom.wordpress.com/

See Also

bowlerWktRateTT getPlayerData

Examples

Run this code
## Not run: 
# # Only away. Get data only for won and lost innings
# kohli <-getPlayerDataTT(253802,dir="../cricketr/data", file="kohli1.csv",
# type="batting")
# 
# # Get bowling data and store in file for future
# ashwin <- getPlayerDataTT(26421,dir="../cricketr/data",file="ashwin1.csv",
# type="bowling")
# ## End(Not run)

Run the code above in your browser using DataLab