The cricketr package has several functions that perform several different analyses on both batsman and bowlers. The package has function that plot percentage frequency runs or wickets, runs likelihood for a batsman, relative run/strike rates of batsman and relative performance/economy rate for bowlers are available.
Other interesting functions include batting performance moving average, forecast and a function to check whether the batsmans in in-form or out-of-form.
The data for a particular player can be obtained with the getPlayerData() function. To do you will need to go to ESPN CricInfo Player and type in the name of the player for e.g Ricky Ponting, Sachin Tendulkar etc. This will bring up a page which have the profile number for the player e.g. for Sachin Tendulkar this would be http://www.espncricinfo.com/india/content/player/35320.html. Hence, Sachin’s profile is 35320. This can be used to get the data for Tendulkar as shown below
Sachin Tendulkar’s performance – Basic Analyses
The 3 plots below provide the following for Tendulkar
- Frequency percentage of runs in each run range over the whole career
- Mean Strike Rate for runs scored in the given range
- A histogram of runs frequency percentages in runs ranges For example
3. Basic analyses
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
- Player 1
- Player 2
- Player 3
- Player 4
4. More analyses
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
Note: For mean strike rate in ODI and Twenty20 use the function batsmanScoringRateODTT()
5.Boxplot histogram plot
This plot shows a combined boxplot of the Runs ranges and a histogram of the Runs Frequency
6. Contribution to won and lost matches
For the 2 functions below you will have to use the getPlayerDataSp() function. I have commented this as I already have these files. This function can only be used for Test matches
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
8. Batsman average at different venues
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
9. Batsman average against different opposition
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
10. Runs Likelihood of batsman
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
11. Moving Average of runs in career
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
12. Cumulative Average runs of batsman in career
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
13. Cumulative Average strike rate of batsman in career
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
14. Future Runs forecast
Here are plots that forecast how the batsman will perform in future. In this case 90% of the career runs trend is uses as the training set. the remaining 10% is the test set.
A Holt-Winters forecating model is used to forecast future performance based on the 90% training set. The forecated runs trend is plotted. The test set is also plotted to see how close the forecast and the actual matches
Take a look at the runs forecasted for the batsman below.
par(mfrow=c(2,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
15. Relative Mean Strike Rate plot
The plot below compares the Mean Strike Rate of the batsman for each of the runs ranges of 10 and plots them. The plot indicate the following
frames <- list("./player1.csv","./player2.csv","player3.csv","player4.csv")
names <- list("Player1","Player2","Player3","Player4")
16. Relative Runs Frequency plot
The plot below gives the relative Runs Frequency Percetages for each 10 run bucket. The plot below show
frames <- list("./player1.csv","./player2.csv","player3.csv","player4.csv")
names <- list("Player1","Player2","Player3","Player4")
17. Relative cumulative average runs in career
frames <- list("./player1.csv","./player2.csv","player3.csv","player4.csv")
names <- list("Player1","Player2","Player3","Player4")
18. Relative cumulative average strike rate in career
frames <- list("./player1.csv","./player2.csv","player3.csv","player4.csv")
names <- list("Player1","Player2","Player3","player4")
20. 3D plot of Runs vs Balls Faced and Minutes at Crease
The plot is a scatter plot of Runs vs Balls faced and Minutes at Crease. A prediction plane is fitted
par(mfrow=c(1,2))
par(mar=c(4,4,2,2))
par(mfrow=c(1,2))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
21. Predicting Runs given Balls Faced and Minutes at Crease
A multi-variate regression plane is fitted between Runs and Balls faced +Minutes at crease.
BF <- seq( 10, 400,length=15)
Mins <- seq(30,600,length=15)
newDF <- data.frame(BF,Mins)
Analysis of bowlers
- Bowler1
- Bowler2
- Bowler3
- Bowler4
player1 <- getPlayerData(xxxx,dir=“..”,file=“player1.csv”,type=“bowling”) Note For One day you will have to use getPlayerDataOD() and for Twenty20 it is getPlayerDataTT()
21. Wicket Frequency Plot
This plot below computes the percentage frequency of number of wickets taken for e.g 1 wicket x%, 2 wickets y% etc and plots them as a continuous line
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
22. Wickets Runs plot
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
23. Average wickets at different venues
24. Average wickets against different opposition
25. Wickets taken moving average
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
26. Cumulative Wickets taken
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
27. Cumulative Economy rate
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
28. Future Wickets forecast
Here are plots that forecast how the bowler will perform in future. In this case 90% of the career wickets trend is used as the training set. the remaining 10% is the test set.
A Holt-Winters forecating model is used to forecast future performance based on the 90% training set. The forecated wickets trend is plotted. The test set is also plotted to see how close the forecast and the actual matches
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
29. Contribution to matches won and lost
As discussed above the next 2 charts require the use of getPlayerDataSp(). This can only be done for Test matches
par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
dev.off()
## null device
## 1
31 Relative Wickets Frequency Percentage
frames <- list("./bowler1.csv","./bowler3.csv","bowler2.csv")
names <- list("Bowler1","Bowler3","Bowler2")
32 Relative Economy Rate against wickets taken
frames <- list("./bowler1.csv","./bowler3.csv","bowler2.csv")
names <- list("Bowler1","Bowler3","Bowler2")
33 Relative cumulative average wickets of bowlers in career
frames <- list("./bowler1.csv","./bowler3.csv","bowler2.csv")
names <- list("Bowler1","Bowler3","Bowler2")
34 Relative cumulative average economy rate of bowlers
frames <- list("./bowler1.csv","./bowler3.csv","bowler2.csv")
names <- list("Bowler1","Bowler3","Bowler2")