Learn R Programming

cricketr (version 0.0.13)

batsmanRunsPredict: Predict the runs for the batsman given the Balls Faced and Minutes in crease

Description

Fit a linear regression plane between Runs scored and Minutes in Crease and Balls Faced. This will be used to predict the batsman runs for time in crease and balls faced

Usage

batsmanRunsPredict(file, name="A Coverdrive", newdataframe)

Arguments

file
This is the .csv file obtained with an initial getPlayerData()
name
Name of the batsman
newdataframe
This is a data frame with 2 columns BF(Balls Faced) and Mins(Minutes)

Value

Returns a data frame with the predicted runs for the Balls Faced and Minutes at crease

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

batsmanMovingAverage battingPerf3d batsmanContributionWonLost

Examples

Run this code
# Get or use the <batsman>.csv obtained with getPlayerData()
# tendulkar <- getPlayerData(35320,file="tendulkar.csv",type="batting", 
# homeOrAway=c(1,2), result=c(1,2,4))

# Use a single value for BF and Mins
BF <- 30
Mins <- 20

# retrieve the file path of a data file installed with cricketr
pathToFile <- system.file("data", "tendulkar.csv", package = "cricketr")
batsmanRunsPredict(pathToFile,"Sachin Tendulkar",newdataframe=data.frame(BF,Mins))

#or give a data frame
#BF <- seq(20,200, length=15)
#Mins <- seq(30,220,length=15)

#values <- batsmanRunsPredict("../cricketr/data/tendulkar.csv","Sachin Tendulkar",
    #newdataframe=data.frame(BF,Runs)
#print(values)

# Note: The above example uses the file tendulkar.csv from the /data directory. However
# you can use any directory as long as the data file exists in that directory.
# The general format is pkg-function(pathToFile,par1,...)

Run the code above in your browser using DataLab