R/batsmanRunsPredict.R

Defines functions batsmanRunsPredict

Documented in batsmanRunsPredict

##########################################################################################
# Designed and developed by Tinniam V Ganesh
# Date : 1 Jul 2015
# Function: batsmanRunsPredict
# This function predicts the runs that will be scored by the batsman for a given numbers
# of balls faced and minutes at crease
#
###########################################################################################
batsmanRunsPredict <- function(file, name="A Coverdrive", newdataframe) {
    batsman <- clean(file)
    
    # Fit a linear regression line between Runs and BF & Mins
    fit <- lm(as.numeric(Runs) ~ BF+Mins,data=batsman)

    # Predict based on the fitted model
    Runs <- predict(fit,newdata=newdataframe)
  
    newdataframe$Runs <- Runs
    names(newdataframe) <- c("Balls Faced","Minutes",'Runs')
    newdataframe
}

Try the cricketr package in your browser

Any scripts or data that you put into this service are public.

cricketr documentation built on March 23, 2021, 9:06 a.m.