The making of cricket package yorkr – Part 3

Introduction

This is the 3rd part of my cricket package yorkr in R. In my 2 earlier posts

  1. The making of cricket package yorkr – Part 1. This post analyzed the performance of team in a ODI match. The batting and bowling performances of the team were analyzed. This post also performed analyses of a country in all matches against another country for e.g. India vs All matches agianst Australia. The best performers with the bat and ball were determined, the best batting partnerships, the performances at different venues etc. The detailed performances of the bowlers of India and Australia in the confrontation were also analyzed.
  2. The making of cricket package yorkr – Part 2 This post includes all ODI matches between a country and others. For obvious reasons I have chosen India and selected all ODI matches played by India with other countries. This included batting and bowling performances of the country against all oppositions.

As mentioned in my earlier posts the data is taken from Cricsheet

If you are passionate about cricket, and love analyzing cricket performances, then check out my 2 racy books on cricket! In my books, I perform detailed yet compact analysis of performances of both batsmen, bowlers besides evaluating team & match performances in Tests , ODIs, T20s & IPL. You can buy my books on cricket from Amazon at $12.99 for the paperback and $4.99/$6.99 respectively for the kindle versions. The books can be accessed at Cricket analytics with cricketr  and Beaten by sheer pace-Cricket analytics with yorkr  A must read for any cricket lover! Check it out!!

1

s), and $4.99/Rs 320 and $6.99/Rs448 respectively

Important note: Do check out my other posts using yorkr at yorkr-posts

Important note: Do check out all the posts on the python avatar of yorkr, namely ‘yorkpy’ in my post ‘Pitching yorkpy … short of good length to IPL – Part 1

In this post I look at individual performances of batsmen and bowlers in ODIs. For this post I have chosen Virat Kohli & Mahendra Singh Dhoni from India. Kohli has been consistent and in great form right through. Dhoni follows Kohli very closely in ODIs. Dhoni besides his shrewd captaincy is one of the best ODI batsman and a great finisher. I have include AB Devilliers from South Africa who seems to invent new strokes and shots every time, much like Glenn Maxwell.

For bowling analyses I have selected RA Jadeja, Harbhajan Singh *the top Indian ODI bowlers) and Mitchell Johnson who is among the best in the world.

This post is also available at RPubs at yorkr-3. You can also download this post as a pdf from yorkr-3.pdf

Checkout my interactive Shiny apps GooglyPlus (plots & tables) and Googly (only plots) which can be used to analyze IPL players, teams and matches.

My earlier package ‘cricketr’ (see Introducing cricketr: An R package for analyzing performances of cricketers) was based on data from ESPN Cricinfo Statsguru. If you want to take a look at my book with all my articles based on my package cricketr at – Cricket analytics with cricketr!!!. The book is also available in paperback and kindle versions at Amazon which has, by the way, better formatting!

I have added some quick observations on the plots below. However there is a lot more that can be discerned from the plots that I can possibly explain. The charts do display a wealth of insights. Do take a close look at the plots.

library(dplyr)
library(ggplot2)
library(yorkr)
library(reshape2)
library(gridExtra)
library(rpart.plot)

1. Batting Details

The following functions get the overall batting details for a country against all opposition.

a <- getTeamBattingDetails("India",save=TRUE)
b <- getTeamBattingDetails("South Africa",save=TRUE)

2. Get Batsman details

Now I get the details of the batsmen Virat Kohli and Mahendra Singh Dhoni from the saved India file and AB De Villiers from the saved South Africa file

kohli <- getBatsmanDetails(team="India",name="Kohli")
dhoni <- getBatsmanDetails(team="India",name="Dhoni")
devilliers <-  getBatsmanDetails(team="South Africa",name="Villiers")

3. Display the dataframe

the dataframe obtained from the calls above provide detailed information for the batsman in every ODI match. This dataframe has all the fields that can be obtained from ESPN Cricinfo

Untitled


 

 

Performance analyses of batsmen

 

4. Runs vs deliveries plot

It can be seen from the plots below that Kohli is very consistent in the runs scored. The runs crowd near the regression curve. There is more variance in Dhoni and De Villiers performance. The band on either side of the regression curve represents the 95% confidence interval(A 95% confidence level means that 95% of the intervals would include the population parameter).

p1 <-batsmanRunsVsDeliveries(kohli,"Kohli")
p2 <- batsmanRunsVsDeliveries(dhoni, "Dhoni")
p3 <- batsmanRunsVsDeliveries(devilliers,"De Villiers")
grid.arrange(p1,p2,p3, ncol=3)

runsDel-1

5. Total runs vs 4s vs 6s plot

The plots below show the runs (Total runs, Runs from 4s & Runs from sixes) vs the deliveries faced. Kohli scores more runs and more fours which can be evaluated from the slope of the blue and red regression lines (reaches 150+,50+) for Total runs and Runs from fours). De Villers has more Runs from sixes as can be seen the 3rd sub plot (green line)

kohli46 <- select(kohli,batsman,ballsPlayed,fours,sixes,runs)
p1 <- batsmanFoursSixes(kohli46,"Kohli")
dhoni46 <- select(dhoni,batsman,ballsPlayed,fours,sixes,runs)
p2 <- batsmanFoursSixes(dhoni46,"Dhoni")
devilliers46 <- select(devilliers,batsman,ballsPlayed,fours,sixes,runs)
p3 <- batsmanFoursSixes(devilliers46, "De Villiers")
grid.arrange(p1,p2,p3, ncol=3)

4s6s-1

6. Batsmen dismissals

Interestingly it can be seen that Dhoni has remained unbeaten more often (47 times) than Kohli or De Villiers. Dhoni despite being a great runner between wickets has been run-out more often.

p1 <-batsmanDismissals(kohli,"Kohli")
p2 <- batsmanDismissals(dhoni, "Dhoni")
p3 <- batsmanDismissals(devilliers, "De Villiers")
grid.arrange(p1,p2,p3, ncol=3)

dismissal-1

7. Batsmen Strike Rate

From the plot below Kohli has the best strike rate till 100 runs, the slope seems to steeper. De Villiers seems to do better after 100 runs.

p1 <-batsmanMeanStrikeRate(kohli,"Kohli")
p2 <- batsmanMeanStrikeRate(dhoni, "Dhoni")
p3 <- batsmanMeanStrikeRate(devilliers, "De Villiers")
grid.arrange(p1,p2,p3, ncol=3)

meanSR-1

8. Batsmen moving average

Kohli’s and De Villiers’ form can be seen to be improving over the years. Dhoni seems to have hit a slump in recent times. But we have to keep in mind that he has the second highest ODI runs in India and is just behind Kohli

p1 <-batsmanMovingAverage(kohli,"Kohli")
p2 <- batsmanMovingAverage(dhoni, "Dhoni")
p3 <- batsmanMovingAverage(devilliers, "De Villiers")
grid.arrange(p1,p2,p3, ncol=3)

bmanMA-1

9. Batsmen against opposition

Kohli averages 50 runs against 6 countries, to Dhoni’s 4. Kohli performs well against Australia, New Zealand, West Indies,Pakistan,Bangladesh. Kohli’s performance against England has been mediocre. De Villiers averages around 50 with 5 countries

batsmanRunsAgainstOpposition(kohli,"Kohli")

bmanOppn-1

batsmanRunsAgainstOpposition(dhoni, "Dhoni")

bmanOppn-2

batsmanRunsAgainstOpposition(devilliers, "De Villiers")

bmanOppn-3

10. Batsmen runs at different venues

Kohli’s favorite hunting grounds in ODI are Adelaide, Sydney, Western Australia, Wankhede. Dhoni’s best performances are at Lords, Sydney,Chepauk.

batsmanRunsVenue(kohli,"Kohli")

bmanOppn1-1

batsmanRunsVenue(dhoni, "Dhoni")

bmanOppn1-2

batsmanRunsVenue(devilliers, "De Villiers")

bmanOppn1-3

11. Batsmen runs predict

The plots below predict the number of deliveries needed by each batsmen to score runs shown. For this I have used classification trees based on deliveries and runs using the package rpart. From the plot for Kohli it can be seen that for 58 deliveries scores around 52 runs. On the other hand De Villiers needs just over 40 deliveries to score 52 runs.

par(mfrow=c(1,3))
par(mar=c(4,4,2,2))
batsmanRunsPredict(kohli,"Kohli")
batsmanRunsPredict(dhoni, "Dhoni")
batsmanRunsPredict(devilliers, "De Villiers")

runsPred-1

dev.off()
## null device 
##           1

12. Get team bowling details

The function below all the ODI matches between India or Australia and all other countries

c <- getTeamBowlingDetails("India",save=TRUE)
d <- getTeamBowlingDetails("Australia",save=TRUE)

13. Get wicket details

The functions below gets the data frame for each bowler

jadeja <- getBowlerWicketDetails(team="India",name="Jadeja")
harbhajan <- getBowlerWicketDetails(team="India",name="Harbhajan")
ashwin <- getBowlerWicketDetails(team="India",name="Ashwin")
johnson <-  getBowlerWicketDetails(team="Australia",name="Johnson")

14. Display data frame

The details of the data frame is shown below

knitr::kable(head(jadeja))
bowler overs maidens runs wickets economyRate date opposition venue
RA Jadeja 6 0 40 0 6.67 2009-02-08 Sri Lanka R Premadasa Stadium
RA Jadeja 7 1 34 0 4.86 2009-06-26 West Indies Sabina Park, Kingston
RA Jadeja 2 0 12 0 6.00 2009-06-28 West Indies Sabina Park, Kingston
RA Jadeja 9 0 39 1 4.33 2009-10-25 Australia Reliance Stadium
RA Jadeja 7 1 35 4 5.00 2009-10-28 Australia Vidarbha Cricket Association Stadium, Jamtha
RA Jadeja 7 1 35 4 5.00 2009-10-28 Australia Vidarbha Cricket Association Stadium, Jamtha

15. Bowler Economy rate

Harbhajan and Ashwin have a better economy rate than RA Jadeja

p1 <- bowlerEconomyRate(jadeja,"RA Jadeja")
p2<-bowlerEconomyRate(harbhajan, "Harbhajan")
p3<-bowlerEconomyRate(ashwin, "Ashwin")
p4<-bowlerEconomyRate(johnson, "MG Johnson")
grid.arrange(p1,p2,p3,p4, ncol=2)

ER-1

15. Mean runs conceded by bowler

p1<-bowlerMeanRuns(jadeja,"RA Jadeja")
p2<-bowlerMeanRuns(harbhajan, "Harbhajan")
p3<-bowlerMeanRuns(ashwin, "Ashwin")
p4<-bowlerMeanRuns(johnson, "MG Johnson")
grid.arrange(p1,p2,p3,p4, ncol=2)

meanRuns-1

15. Moving average of bowler

From the plots below MG Johnson, Harbhajan and Ashwin have been performing very consistently. RA Jadeja bowling seems to be taking a nosedive, though he is at the top of all ODI bowlers of India

p1<-bowlerMovingAverage(jadeja,"RA Jadeja")
p2<-bowlerMovingAverage(harbhajan, "Harbhajan")
p3<-bowlerMovingAverage(ashwin, "Ashwin")
p4<-bowlerMovingAverage(johnson, "MG Johnson")
grid.arrange(p1,p2,p3,p4, ncol=2)

bwlrMA-1

16. Wicket average

Jadeja has a better wicket average than Harbhajan and Ashwin.Jadeja and Ashwin average around 2 wickets Harbhajan averages 1.5 wickets(tendency to 2)

p1<-bowlerWicketPlot(jadeja,"RA Jadeja")
p2<-bowlerWicketPlot(harbhajan, "Harbhajan")
p3<-bowlerWicketPlot(ashwin, "Ashwin")
p4<-bowlerWicketPlot(johnson, "MG Johnson")
grid.arrange(p1,p2,p3,p4, ncol=2)

bwlrWkt-1

16. Wickets opposition

Jadeja’s best performances have been against England, Pakistan, New Zealand and Zimbabwe. For Harbhajan it has been New Zealand, Sri Lanka and Zimbabwe.

bowlerWicketsAgainstOpposition(jadeja,"RA Jadeja")

bwlrOppn-1

bowlerWicketsAgainstOpposition(harbhajan, "Harbhajan")

bwlrOppn-2

bowlerWicketsAgainstOpposition(ashwin, "Ashwin")

bwlrOppn-3

bowlerWicketsAgainstOpposition(johnson, "MG Johnson")

bwlrOppn-4

16. Wickets venue

The top 20 venues for each bowler is shown in the plots

bowlerWicketsVenue(jadeja,"RA Jadeja")

bwlrVenue-1

bowlerWicketsVenue(harbhajan, "Harbhajan")

bwlrVenue-2

bowlerWicketsVenue(ashwin, "Ashwin")

bwlrVenue-3

bowlerWicketsVenue(johnson, "MG Johnson")

bwlrVenue-4

16. Create a data frame with wickets and deliveries

jadeja1 <- getDeliveryWickets(team="India",name="Jadeja",save=FALSE)
harbhajan1 <- getDeliveryWickets(team="India",name="Harbhajan",save=FALSE)
ashwin1 <- getDeliveryWickets(team="India",name="Ashwin",save=FALSE)
johnson1 <- getDeliveryWickets(team="Australia",name="MG Johnson",save=FALSE)

17. Deliveries to wickets plots

The following plots try to predict the average number of deliveries required for the wickets taken. As in the batsman runs predict I have used classification trees between deliverie at which a wicket was taken. The package rpart was used for the classification. The internediate nodes are the number of deliveries and the leaf nodes are the wickets taken. Though the wickets are in decimal we can intepret the tree as follows For RA Jadeja 22 to take 1.6 wicket (~2 wickets). Interestingly Harbhajan needs

par(mfrow=c(1,2))
par(mar=c(4,4,2,2))
bowlerWktsPredict(jadeja1,"RA Jadeja")
bowlerWktsPredict(harbhajan1,"Harbhajan Sigh")

wktPrd1-1

dev.off()
## null device 
##           1

Similarly MG Johnson can provide a breakthrough with just around 14 deliveries

par(mfrow=c(1,2))
par(mar=c(4,4,2,2))
bowlerWktsPredict(ashwin1,"Ravichander Ashwin")
bowlerWktsPredict(johnson1,"MG Johnson")

wktPred2-1

dev.off()
## null device 
##           1

Conclusion

ODI batsman

  1. The top 2 ODI Indian batsman(Kohli and Dhoni) and De Villiers of South Africa were considered.
  2. Kohli has a better strike rate till about 100 runs(steeper slope) and De Villiers beyond 100.
  3. Dhoni has remained unbeaten more number of times than the other 2. It may have been possible that his average would have been higher if he had come in earlier
  4. Kohli and De Villiers have performed consistently. Dhoni needs to get back his touch

ODI bowlers

  1. RA Jadeja has a better wicket taking rate than Harbhajan and Ashwin.
  2. Ashwin and Harbhajan have a better economy rate than Jadeja
  3. Harbhjanan, Ashwin and MG Johnson have performed consistently while RA Jadeja’s performance has been on the decline.
  4. Harbhajan and MG Johnson need around 11 balls to make a break through

This was probably the last set of functions for my cricket package yorkr. Over the next several weeks I will be cleaning up, documenting, refining the functions and removing any glitches. I hope to have the package released in the next 6-8 weeks

Also see

  1. Cricket analytics with cricketr
  2. Sixer: An R package cricketr’s new Shiny avatar

You may also like

  1. What’s up Watson? Using IBM Watson’s QAAPI with Bluemix, NodeExpress
  2. The common alphabet of programming languages
  3. A method to crowd source pothole marking on (Indian) roads
  4. The Anomaly
  5. Simulating the domino effect in Android using Box2D and AndEngine
  6. Presentation on Wireless Technologies – Part 1
  7. Natural selection of database technology through the years

The making of cricket package yorkr – Part 2

Introduction

In this post (The making of cricket package yorkr-Part 2),  I continue to add new functionality to my package cricket package yorkr in R. In my earlier post The making of cricket package yorkr-Part 1 I had included functionality that will plot batsman partnerships, bowlers performances with wicket-kind, wicket-runs in specified ODI match. The earlier post also included functions that were based on confrontations between any 2 teams ( I had chosen the ODI matches between India and Australia).

If you are passionate about cricket, and love analyzing cricket performances, then check out my 2 racy books on cricket! In my books, I perform detailed yet compact analysis of performances of both batsmen, bowlers besides evaluating team & match performances in Tests , ODIs, T20s & IPL. You can buy my books on cricket from Amazon at $12.99 for the paperback and $4.99/$6.99 respectively for the kindle versions. The books can be accessed at Cricket analytics with cricketr  and Beaten by sheer pace-Cricket analytics with yorkr  A must read for any cricket lover! Check it out!!

1

320 and $6.99/Rs448 respectively

 

Checkout my interactive Shiny apps GooglyPlus (plots & tables) and Googly (only plots) which can be used to analyze IPL players, teams and matches.

Important note: Do check out all the posts on the python avatar of yorkr, namely ‘yorkpy’ in my post ‘Pitching yorkpy … short of good length to IPL – Part 1

This post includes all ODI matches between a country and others. For obvious reasons I have chosen India and selected all ODI matches played by India with other countries. As mentioned in my earlier post the data is taken from Cricsheet. There are a total of 262 ODI matches that India has played. These 262 ODI matches played by India are then combined into one large dataframe that is 140,655 rows x 22 columns.

The analysis is then done on India’s batting and bowling performances on this huge dataframe for e.g. who has the most scores and highest batting partnerships, which bowlers are most effective against a country. Also the functions give details like which Indian bowlers have the worst performance or which bowlers have taken the most wicket against India. The functions also provide information on batsmen and bowlers of the opposing countries who have performed welll against India. Since the dataset is large and rich, the possible insights are infinite.I am including some functions that I have created on this dataset below.

Also note that it is possible to choose all ODI matches played by Australia, Pakistan, South Africa etc with the rest of the world. Similar analysis can be done for these countries also by using the functions below

As before the package ‘yorkr’ is still under development. I will be releasing the package and code in about 6-10 weeks time. Please be patient.

This post is also available at RPubs at yorkr-2. You can download this post as a PDF document at yorkr-2.pdf

My earlier package ‘cricketr’ (see Introducing cricketr: An R package for analyzing performances of cricketers) was based on data from ESPN Cricinfo Statsguru. Take a look at my book with all my articles based on my package cricketr at – Cricket analytics with cricketr!!!. The book is also available in paperback and kindle versions at Amazon which has, by the way, better formatting!

library(dplyr)
library(ggplot2)
library(yorkr)
matches <- getAllMatches("India",save=FALSE)
dim(matches)
## [1] 140655     22

1. Team Batting details – India

The following function provides the overall batting performance of India against all opposition

Virat Kohli has the best performance with a total of 7023 runs in ODIs followed closely by Mahendra Dhoni with 6885 runs and then Suresh Raina with 4964 runs While Kohli leads in the numnber of 4s (662), Dhoni and Raina has twice the number of 6s as compared to Kohli. However Kohli has a better strike rate (7023/774100) = 90.33% while Dhoni has an overall strike rate of (6885/7878100) = 87.39%

df <-teamBattingDetailsAllOppn(matches,theTeam="India")
## Total= 58033
df
## Source: local data frame [71 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1       V Kohli        7774   662    65  7023
## 2      MS Dhoni        7878   515   129  6885
## 3      SK Raina        5076   429   114  4964
## 4     G Gambhir        5138   470    15  4495
## 5     RG Sharma        5245   370    89  4377
## 6  SR Tendulkar        4708   504    43  4196
## 7  Yuvraj Singh        4472   403    96  3976
## 8      V Sehwag        3102   494    74  3679
## 9      S Dhawan        2956   314    37  2694
## 10    AM Rahane        2490   194    24  2005
## ..          ...         ...   ...   ...   ...

2. Team batting details – Other countries against India

When we use other countries in theTeam then we get the performance of batsman of these countries against India in ODIs. This is because matches is a selection of all matches played by India against other countries. The following there calls show the performances of the batsman of England, South Africa, Pakistan & Ireland against India.

df <-teamBattingDetailsAllOppn(matches,theTeam="England")
## Total= 7602
df
## Source: local data frame [43 x 5]
## 
##           batsman ballsPlayed fours sixes  runs
##            (fctr)       (int) (int) (int) (dbl)
## 1         IR Bell        1238   110     9  1085
## 2    KP Pietersen         990    89    10   847
## 3         AN Cook        1049   103     2   822
## 4       RS Bopara         632    42     8   534
## 5  PD Collingwood         450    38     6   393
## 6         OA Shah         394    40     7   385
## 7       IJL Trott         410    33     2   349
## 8         JE Root         408    32     4   336
## 9        SR Patel         336    25    10   329
## 10   C Kieswetter         309    34    13   313
## ..            ...         ...   ...   ...   ...
df <-teamBattingDetailsAllOppn(matches,theTeam="South Africa")
## Total= 6172
df
## Source: local data frame [36 x 5]
## 
##           batsman ballsPlayed fours sixes  runs
##            (fctr)       (int) (int) (int) (dbl)
## 1  AB de Villiers        1026   102    38  1179
## 2         HM Amla         796    74     1   704
## 3       Q de Kock         637    76     8   633
## 4       JH Kallis         666    50     4   554
## 5       JP Duminy         477    19     9   438
## 6    F du Plessis         470    30     8   421
## 7        GC Smith         355    25     3   252
## 8        HH Gibbs         318    26     3   242
## 9      MN van Wyk         270    23     1   202
## 10      DA Miller         188    19     4   193
## ..            ...         ...   ...   ...   ...
df <-teamBattingDetailsAllOppn(matches,theTeam="Pakistan")
## Total= 4660
df
## Source: local data frame [37 x 5]
## 
##            batsman ballsPlayed fours sixes  runs
##             (fctr)       (int) (int) (int) (dbl)
## 1      Younis Khan         752    56     8   686
## 2     Shoaib Malik         669    61     4   595
## 3    Misbah-ul-Haq         619    49     6   550
## 4      Salman Butt         617    69     4   535
## 5  Mohammad Yousuf         458    37     2   432
## 6    Nasir Jamshed         473    41     4   408
## 7  Mohammad Hafeez         423    36     3   347
## 8    Shahid Afridi         187    16     7   235
## 9     Kamran Akmal         235    20     5   192
## 10      Umar Akmal         146     7     2   103
## ..             ...         ...   ...   ...   ...
df <-teamBattingDetailsAllOppn(matches,theTeam="Bangladesh")
## Total= 3761
df
## Source: local data frame [39 x 5]
## 
##              batsman ballsPlayed fours sixes  runs
##               (fctr)       (int) (int) (int) (dbl)
## 1    Mushfiqur Rahim         658    34    13   517
## 2        Tamim Iqbal         573    61     6   504
## 3    Shakib Al Hasan         591    42     5   493
## 4        Mahmudullah         310    27     1   269
## 5      Raqibul Hasan         262    11     3   202
## 6      Nasir Hossain         187    21     1   183
## 7  Mohammad Ashraful         235    17    NA   158
## 8      Soumya Sarkar         164    18     5   157
## 9        Imrul Kayes         183    21     1   155
## 10     Sabbir Rahman         142    16     1   136
## ..               ...         ...   ...   ...   ...

3. Top batting partnership report – India

The following functions show the top partnerships among Indian batsman in ODIs. Virat Kohli leads the way with 7023 runs followed by Mahendra Singh Dhoni with 6885 runs and Sures Raina in the 3rd pace.

The detailed report gives the breakup of the partnerships. It can be seen that Kohli has had the best partnership with Rohot Sharma and Suresh Raina. Dhoni best partnership is with Raina

a <- batsmanPartnershiAllOppn(matches,theTeam="India",report="summary")
a
## Source: local data frame [71 x 2]
## 
##         batsman totalRuns
##          (fctr)     (dbl)
## 1       V Kohli      7023
## 2      MS Dhoni      6885
## 3      SK Raina      4964
## 4     G Gambhir      4495
## 5     RG Sharma      4377
## 6  SR Tendulkar      4196
## 7  Yuvraj Singh      3976
## 8      V Sehwag      3679
## 9      S Dhawan      2694
## 10    AM Rahane      2005
## ..          ...       ...
b <- batsmanPartnershiAllOppn(matches,theTeam="India",report="detailed")
b[1:50,]
##     batsman      nonStriker partnershipRuns totalRuns
## 1   V Kohli        S Dhawan             657      7023
## 2   V Kohli       AM Rahane             502      7023
## 3   V Kohli       RG Sharma            1073      7023
## 4   V Kohli      KD Karthik             139      7023
## 5   V Kohli    SR Tendulkar             272      7023
## 6   V Kohli        R Dravid             132      7023
## 7   V Kohli        V Sehwag             255      7023
## 8   V Kohli    Yuvraj Singh             420      7023
## 9   V Kohli        SK Raina            1072      7023
## 10  V Kohli        MS Dhoni             534      7023
## 11  V Kohli Harbhajan Singh              13      7023
## 12  V Kohli       IK Pathan               1      7023
## 13  V Kohli               4               0      7023
## 14  V Kohli       G Gambhir             962      7023
## 15  V Kohli      RV Uthappa              10      7023
## 16  V Kohli       RA Jadeja              91      7023
## 17  V Kohli        R Ashwin              71      7023
## 18  V Kohli       AT Rayudu             345      7023
## 19  V Kohli Gurkeerat Singh               1      7023
## 20  V Kohli       YK Pathan              68      7023
## 21  V Kohli       STR Binny               4      7023
## 22  V Kohli       MK Tiwary             105      7023
## 23  V Kohli        AR Patel              39      7023
## 24  V Kohli        PA Patel             180      7023
## 25  V Kohli               6               0      7023
## 26  V Kohli         M Vijay              33      7023
## 27  V Kohli       KM Jadhav              10      7023
## 28  V Kohli        AM Nayar              25      7023
## 29  V Kohli     S Badrinath               9      7023
## 30 MS Dhoni        S Dhawan              49      6885
## 31 MS Dhoni       AM Rahane              50      6885
## 32 MS Dhoni       RG Sharma             300      6885
## 33 MS Dhoni      KD Karthik             158      6885
## 34 MS Dhoni    SR Tendulkar             325      6885
## 35 MS Dhoni        R Dravid             239      6885
## 36 MS Dhoni        V Sehwag             188      6885
## 37 MS Dhoni    Yuvraj Singh             837      6885
## 38 MS Dhoni        SK Raina            1423      6885
## 39 MS Dhoni          M Kaif              47      6885
## 40 MS Dhoni        D Mongia              47      6885
## 41 MS Dhoni      AB Agarkar               8      6885
## 42 MS Dhoni Harbhajan Singh              90      6885
## 43 MS Dhoni        RP Singh              95      6885
## 44 MS Dhoni        MM Patel               0      6885
## 45 MS Dhoni       IK Pathan             156      6885
## 46 MS Dhoni       G Gambhir             596      6885
## 47 MS Dhoni      RV Uthappa             137      6885
## 48 MS Dhoni     S Sreesanth              23      6885
## 49 MS Dhoni        I Sharma              67      6885
## 50 MS Dhoni         P Kumar              64      6885

4. Top batting partnership report – Other countries against India

Since matches already has selected all matches played by India with every other country calling the function with theTeam=“Australia” or “South Africa” will display those batsman who had the best partnerships in matches against India. It can be seen that Ponting, Hussey and Bailey lead against India while for the SOuth Africans it is De Villiers, Hashim Amla and Q De Kock.

a <- batsmanPartnershiAllOppn(matches,theTeam="Australia",report="summary")
a
## Source: local data frame [48 x 2]
## 
##       batsman totalRuns
##        (fctr)     (dbl)
## 1  RT Ponting       876
## 2  MEK Hussey       753
## 3   GJ Bailey       610
## 4   SR Watson       609
## 5   MJ Clarke       607
## 6   ML Hayden       573
## 7   A Symonds       536
## 8    AJ Finch       525
## 9   SPD Smith       467
## 10  DA Warner       391
## ..        ...       ...
b <- batsmanPartnershiAllOppn(matches,theTeam="South Africa",report="summary")
b
## Source: local data frame [36 x 2]
## 
##           batsman totalRuns
##            (fctr)     (dbl)
## 1  AB de Villiers      1179
## 2         HM Amla       704
## 3       Q de Kock       633
## 4       JH Kallis       554
## 5       JP Duminy       438
## 6    F du Plessis       421
## 7        GC Smith       252
## 8        HH Gibbs       242
## 9      MN van Wyk       202
## 10      DA Miller       193
## ..            ...       ...

5. Top batting partnership plots

The following plots display the above partnershi[p details graphically

batsmanPartnershipAllOppnPlot(matches,"India","All")

partnership-1-1

batsmanPartnershipAllOppnPlot(matches,"India","Australia")

partnership-1-2

batsmanPartnershipAllOppnPlot(matches,"India","South Africa")

partnership-1-3

dim(matches)
## [1] 140655     22

6. Batsman vs bowlers report

The reports below show how the Indian batsman fared against bowlers of other countries. Using rank=0 shows the top 10 batsman of India. Specificying a rank ‘i’ will show against which bowlers the batsman scored maximum runs. Kohli has made most runs against Perera, Kulasekara and Malinga.Dhoni against Muralidharan, Jayasuriya and Malinga. Surprisingly Tendulkars runs ODIs have come Mitchell Johnson, Brett Lee and James Anderson.

a <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=0)
a
## Source: local data frame [10 x 2]
## 
##         batsman runsScored
##          (fctr)      (dbl)
## 1       V Kohli       7023
## 2      MS Dhoni       6885
## 3      SK Raina       4964
## 4     G Gambhir       4495
## 5     RG Sharma       4377
## 6  SR Tendulkar       4196
## 7  Yuvraj Singh       3976
## 8      V Sehwag       3679
## 9      S Dhawan       2694
## 10    AM Rahane       2005
b <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=1)
b
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##    batsman          bowler  runs
##     (fctr)          (fctr) (dbl)
## 1  V Kohli     NLTC Perera   242
## 2  V Kohli KMDN Kulasekara   196
## 3  V Kohli      SL Malinga   175
## 4  V Kohli      AD Mathews   155
## 5  V Kohli      BAW Mendis   132
## 6  V Kohli       R Rampaul   127
## 7  V Kohli     JW Dernbach   121
## 8  V Kohli     JP Faulkner   118
## 9  V Kohli       DJG Sammy   116
## 10 V Kohli    HMRKB Herath   113
## ..     ...             ...   ...
b <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=2)
b
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##     batsman         bowler  runs
##      (fctr)         (fctr) (dbl)
## 1  MS Dhoni M Muralitharan   195
## 2  MS Dhoni  ST Jayasuriya   183
## 3  MS Dhoni     SL Malinga   144
## 4  MS Dhoni      SR Watson   135
## 5  MS Dhoni        ST Finn   130
## 6  MS Dhoni     MG Johnson   128
## 7  MS Dhoni    JP Faulkner   125
## 8  MS Dhoni  Shahid Afridi   120
## 9  MS Dhoni     TT Bresnan   111
## 10 MS Dhoni     AD Mathews   111
## ..      ...            ...   ...
b <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=3)
b
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##     batsman           bowler  runs
##      (fctr)           (fctr) (dbl)
## 1  SK Raina         S Randiv   124
## 2  SK Raina      NLTC Perera   124
## 3  SK Raina       TT Bresnan   113
## 4  SK Raina Mashrafe Mortaza   108
## 5  SK Raina  KMDN Kulasekara   104
## 6  SK Raina       SL Malinga    96
## 7  SK Raina      JW Dernbach    94
## 8  SK Raina          ST Finn    93
## 9  SK Raina      JC Tredwell    86
## 10 SK Raina       T Thushara    84
## ..      ...              ...   ...
b <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=6)
b
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##         batsman          bowler  runs
##          (fctr)          (fctr) (dbl)
## 1  SR Tendulkar      MG Johnson   178
## 2  SR Tendulkar           B Lee   137
## 3  SR Tendulkar     JM Anderson   133
## 4  SR Tendulkar      SL Malinga   133
## 5  SR Tendulkar KMDN Kulasekara   127
## 6  SR Tendulkar        JR Hopes    94
## 7  SR Tendulkar        Umar Gul    92
## 8  SR Tendulkar       SCJ Broad    89
## 9  SR Tendulkar    IDR Bradshaw    85
## 10 SR Tendulkar      BAW Mendis    80
## ..          ...             ...   ...

7.Batsman vs bowlers report – Bowlers of other countries against India

As before using another team for theTeam e.g. West Indies or Pakistan will show the batsman of those countries who made the most runs against India in ODIs. The reports below show the performances of batsmen from West Indies, Bangladesh and Zimbabwe.

a <- batsmanVsBowlersAllOppnRept(matches,theTeam="West Indies",rank=0)
a
## Source: local data frame [10 x 2]
## 
##        batsman runsScored
##         (fctr)      (dbl)
## 1    RR Sarwan        655
## 2   MN Samuels        653
## 3     DM Bravo        523
## 4  LMP Simmons        426
## 5     CH Gayle        414
## 6   KA Pollard        359
## 7    DJG Sammy        348
## 8   AD Russell        308
## 9     DJ Bravo        301
## 10     BC Lara        268
a <- batsmanVsBowlersAllOppnRept(matches,theTeam="Ireland",rank=0)
a
## Source: local data frame [10 x 2]
## 
##            batsman runsScored
##             (fctr)      (dbl)
## 1       NJ O'Brien        173
## 2  WTS Porterfield        158
## 3      DT Johnston         51
## 4      PR Stirling         42
## 5        AR Cusack         35
## 6      A Balbirnie         24
## 7        GC Wilson         19
## 8         DI Joyce         18
## 9        JF Mooney         17
## 10        AR White         13
a <- batsmanVsBowlersAllOppnRept(matches,theTeam="Zimbabwe",rank=0)
a
## Source: local data frame [10 x 2]
## 
##          batsman runsScored
##           (fctr)      (dbl)
## 1     BRM Taylor        328
## 2   E Chigumbura        322
## 3    H Masakadza        285
## 4  Sikandar Raza        202
## 5    SC Williams        186
## 6   CJ Chibhabha        158
## 7      V Sibanda        140
## 8      CR Ervine         94
## 9       P Utseya         71
## 10   R Mutumbami         61

8. Batsman vs bowlers plots

df <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=1)
batsmanVsBowlersAllOppnPlot(df)

batsmanvsbowler-1

df <- batsmanVsBowlersAllOppnRept(matches,theTeam="India",rank=2)
batsmanVsBowlersAllOppnPlot(df)

batsmanvsbowler-2

df <- batsmanVsBowlersAllOppnRept(matches,theTeam="South Africa",rank=1)
d <- complete.cases(df) # Remove NAs
df <- df[d,]
batsmanVsBowlersAllOppnPlot(df)

batsmanvsbowler-3

df <- batsmanVsBowlersAllOppnRept(matches,theTeam="Pakistan",rank=3)
d <- complete.cases(df) # Remove NAs
df <- df[d,]
batsmanVsBowlersAllOppnPlot(df)

batsmanvsbowler-4

9. Top ODI bowlers of India

The overall bowling performance of all Indian bowlers in all ODI matches played so far is computed in the function below. The top 5 Indian ODI bowlers with the best ODI performance are

  1. Ravindra Jadeja
  2. Ravichander Ashwin
  3. Zaheer Khan
  4. Harbhajan Singh
  5. Ishant Sharma
df <- teamBowlingDetailsAllOppnMain(matches,theTeam="India")
df
## Source: local data frame [59 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1        RA Jadeja    43       0  4743     153
## 2         R Ashwin    49       0  4209     146
## 3           Z Khan    47       0  3686     141
## 4  Harbhajan Singh    45       0  4032     123
## 5         I Sharma    51       0  3216     113
## 6         MM Patel    49       1  2392      92
## 7          P Kumar    50       2  2748      84
## 8         UT Yadav    51       0  2442      80
## 9   Mohammed Shami    43       0  1802      80
## 10    Yuvraj Singh    38       0  2588      77
## ..             ...   ...     ...   ...     ...

10. Top ODI bowlers of other countries against India

The tables below provide the details of the bowlers who have the best performances against India. This is obtained when theteam=“India”. Mitchell Johnson has a haul of 44 wicke taken at 1012 runs followed by Kulaseka who has 40 wickets for 1492 and then Mendis who has taken 34 wickets for 810 runs

df <- teamBowlingDetailsAllOppn(matches,theTeam="India")
df
## Source: local data frame [309 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1       MG Johnson    47       0  1012      44
## 2  KMDN Kulasekara    44       0  1492      40
## 3       BAW Mendis    37       0   810      34
## 4         DW Steyn    35       1   714      34
## 5       SL Malinga    48       1  1402      33
## 6      JM Anderson    31       0   991      33
## 7       AD Mathews    47       1   800      31
## 8      NLTC Perera    45       0   983      30
## 9          ST Finn    38       0   775      30
## 10       SCJ Broad    29       2   903      29
## ..             ...   ...     ...   ...     ...

11. Top ODI bowlers of other countries against India

The tables below give the performances of Indian bowlers against different opposition. Against Australia the top 3 bowlers are Ishant Sharma, Harbhajan Singh and Irfan Pathan. FOr ODI matches against England the top 3 are Jadeja, Ashwin and Munaf Patel. The tables are for matches against South Africa and Pakistan are also included

df <- teamBowlingDetailsAllOppn(matches,theTeam="Australia")
df
## Source: local data frame [37 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1         I Sharma    44       1   739      26
## 2  Harbhajan Singh    40       0   926      25
## 3        IK Pathan    42       1   702      22
## 4         UT Yadav    37       2   606      18
## 5      S Sreesanth    34       0   454      18
## 6        RA Jadeja    39       0   867      16
## 7           Z Khan    33       1   500      15
## 8         R Ashwin    43       0   680      14
## 9          P Kumar    27       0   501      14
## 10   R Vinay Kumar    31       1   380      14
## ..             ...   ...     ...   ...     ...
df <- teamBowlingDetailsAllOppn(matches,theTeam="England")
df
## Source: local data frame [32 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1        RA Jadeja    34       0   735      35
## 2         R Ashwin    32       0   792      34
## 3         MM Patel    16       0   478      18
## 4           Z Khan    26       1   518      17
## 5         RP Singh    19       1   438      12
## 6         I Sharma    32       1   418      12
## 7         RR Powar    22       0   259      11
## 8          B Kumar    17       1   367      10
## 9         SK Raina    17       0   238      10
## 10 Harbhajan Singh    15       0   293       9
## ..             ...   ...     ...   ...     ...
df <- teamBowlingDetailsAllOppn(matches,theTeam="South Africa")
df
## Source: local data frame [33 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1           Z Khan    19       1   552      25
## 2  Harbhajan Singh    31       0   580      15
## 3         MM Patel    19       0   310      15
## 4   Mohammed Shami     9       1   215      11
## 5     Yuvraj Singh    17       0   279       9
## 6        RA Jadeja    18       1   299       8
## 7          A Nehra    27       1   366       7
## 8        MM Sharma    16       0   307       7
## 9      S Sreesanth    18       0   266       7
## 10         B Kumar    11       0   374       6
## ..             ...   ...     ...   ...     ...
df <- teamBowlingDetailsAllOppn(matches,theTeam="Pakistan")
df
## Source: local data frame [28 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1         I Sharma    32       1   405      14
## 2           Z Khan    20       0   284      12
## 3        IK Pathan    30       3   504      10
## 4          P Kumar    24       0   387      10
## 5  Harbhajan Singh    29       0   339      10
## 6         RP Singh    25       1   319      10
## 7         R Ashwin    22       0   302      10
## 8        RA Jadeja    23       2   250      10
## 9          B Kumar    14       0   194       9
## 10    Yuvraj Singh    16       0   241       6
## ..             ...   ...     ...   ...     ...

12. Top Indian ODI bowlers vs batsman

The reports below give the performances of bowlers against opposition batsman 1.The 1st call with theteam=“India” and rank=0 gives the bowlers who have conceded the most runs against India 2. The 2nd call with rank=1 gives the names of Indian batsman who scored the most against India 3. The 3rd call gives the performance of Malinga who has conceded the 2nd most runs in ODIs against India and the batsman who made these runs

a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="India",rank=0)
a
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1  KMDN Kulasekara  1448
## 2       SL Malinga  1319
## 3      NLTC Perera   959
## 4      JM Anderson   954
## 5       MG Johnson   931
## 6        SCJ Broad   877
## 7       BAW Mendis   783
## 8       AD Mathews   776
## 9          ST Finn   751
## 10        DJ Bravo   739
a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="India",rank=1)
a
## Source: local data frame [31 x 3]
## Groups: bowler [1]
## 
##             bowler      batsman runsConceded
##             (fctr)       (fctr)        (dbl)
## 1  KMDN Kulasekara     V Sehwag          199
## 2  KMDN Kulasekara      V Kohli          196
## 3  KMDN Kulasekara    G Gambhir          157
## 4  KMDN Kulasekara SR Tendulkar          127
## 5  KMDN Kulasekara Yuvraj Singh          118
## 6  KMDN Kulasekara    RG Sharma          114
## 7  KMDN Kulasekara     SK Raina          104
## 8  KMDN Kulasekara     MS Dhoni           80
## 9  KMDN Kulasekara   KD Karthik           56
## 10 KMDN Kulasekara   SC Ganguly           51
## ..             ...          ...          ...
a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="India",rank=2)
a
## Source: local data frame [31 x 3]
## Groups: bowler [1]
## 
##        bowler      batsman runsConceded
##        (fctr)       (fctr)        (dbl)
## 1  SL Malinga      V Kohli          175
## 2  SL Malinga    G Gambhir          170
## 3  SL Malinga     MS Dhoni          144
## 4  SL Malinga     V Sehwag          140
## 5  SL Malinga SR Tendulkar          133
## 6  SL Malinga     SK Raina           96
## 7  SL Malinga Yuvraj Singh           64
## 8  SL Malinga   KD Karthik           52
## 9  SL Malinga    RG Sharma           50
## 10 SL Malinga   RV Uthappa           47
## ..        ...          ...          ...

13. Top ODI bowlers of other countries vs batsman

When we use other teams in theTeam we get the names of Indian bowlers

a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="Sri Lanka",rank=0)
a
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1           Z Khan  1141
## 2        RA Jadeja   882
## 3         I Sharma   855
## 4  Harbhajan Singh   805
## 5          P Kumar   758
## 6         R Ashwin   736
## 7        IK Pathan   674
## 8          A Nehra   584
## 9         UT Yadav   544
## 10        MM Patel   484
a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="England",rank=0)
a
## Source: local data frame [10 x 2]
## 
##          bowler  runs
##          (fctr) (dbl)
## 1      R Ashwin   777
## 2     RA Jadeja   729
## 3        Z Khan   503
## 4      MM Patel   459
## 5      RP Singh   410
## 6      I Sharma   396
## 7     PP Chawla   375
## 8  Yuvraj Singh   370
## 9       B Kumar   353
## 10   AB Agarkar   336
a <- bowlersVsBatsmanAllOppnRept(matches,theTeam="New Zealand",rank=0)
a
## Source: local data frame [10 x 2]
## 
##            bowler  runs
##            (fctr) (dbl)
## 1        R Ashwin   456
## 2       RA Jadeja   363
## 3    Yuvraj Singh   320
## 4  Mohammed Shami   304
## 5         A Nehra   302
## 6         P Kumar   289
## 7        I Sharma   281
## 8          Z Khan   238
## 9         B Kumar   233
## 10       MM Patel   213

14. Top ODI bowlers vs batsman plots

The plots below give the the performances of bowlers against batsman. The logic is same as above

df <- bowlersVsBatsmanAllOppnRept(matches,theTeam="India",rank=1)
bowlerVsBatsmanAllOppnPlot(df,"India","India")

bowlerBatsman-1

df <- bowlersVsBatsmanAllOppnRept(matches,theTeam="England",rank=1)
bowlerVsBatsmanAllOppnPlot(df,"India","England")

bowlerBatsman-2

df <- bowlersVsBatsmanAllOppnRept(matches,theTeam="Australia",rank=1)
bowlerVsBatsmanAllOppnPlot(df,"India","England")

bowlerBatsman-3

15. Top ODI bowlers wicket kind

The following plots give the top 8 bowlers against India and the wicket kind taken

teamBowlingWicketKindAllOppn(matches,t1="India",t2="All")

wicketKind-1-1

The plots below give the top 8 Indian bowlers against different countries

teamBowlingWicketKindAllOppn(matches,t1="India",t2="Bangladesh")

wicketKind-2-1

teamBowlingWicketKindAllOppn(matches,t1="India",t2="New Zealand")

wicketKind-2-2

teamBowlingWicketKindAllOppn(matches,t1="India",t2="West Indies")

wicketKind-2-3

teamBowlingWicketKindAllOppn(matches,t1="India",t2="Sri Lanka")

wicketKind-2-4

16. Top ODI bowlers  wicket runs

The plot below gives the top 8 performances of bowlers against India with wickets taken and runs conceded. The maximum wickets is 44 (pink) and Mitchell Johnson has taken it conceding around 1000 runs. Kulasekara has 40 wickets (purple) conceding around 1400 runs

teamBowlingWicketRunsAllOppn(matches,t1="India",t2="All")

wicketRuns-1-1

The plots below give the top 8 Indian bowlers against different countries. The bar that is rightmost is the most wickets and the taller the bar more the runs conceded.

teamBowlingWicketRunsAllOppn(matches,t1="India",t2="Zimbabwe")

wicketRuns-2-1

teamBowlingWicketRunsAllOppn(matches,t1="India",t2="Australia")

wicketRuns-2-2

teamBowlingWicketRunsAllOppn(matches,t1="India",t2="Pakistan")

wicketRuns-2-3

teamBowlingWicketRunsAllOppn(matches,t1="India",t2="New Zealand")

wicketRuns-2-4

Important note: Do check out my other posts using yorkr at yorkr-posts

Conclusion

Here are some quick conclusions I have gleaned from the analysis

  1. Virat Kohli has the highest runs in ODI, followed by Mahendra Dhoni and then Suresh Raina.
  2. Though Kohli has the best strike rate, Dhoni and Raina have twice the number of 6’s as Kohli.
  3. Among batsmen from other countries that have to be feared are GJ Bailey, Younis Khan, AB Devillers etc
  4. Among Indian ODI bowlers Ravindra Jadeja, Ashwin and Zaheer Khan have the most wickets. 5.Ishant Sharma, Harbhajan Singh performed well against Australia and RA Jadeja,Ashwin against England and so on
  5. India has to be wary of Mitchell Johnson,Kulasekara, Malinga

Also see

  1. Cricket analytics with cricketr in paperback and Kindle versions
  2. Introducing cricketr! : An R package to analyze performances of cricketers
  3. Cricketr plays the ODIs
  4. Cricketr adapts to Twenty20 International

You may also like

  1. Revisiting crimes against women in India
  2. Literacy in India – A deepR dive
  3. Bend it like Bluemix,MongoDB using Autoscaling – Part 2
  4. A closer look at Robot Horse on a trot in Android
  5. Programming Zen and now – Sime essential tips
  6. Design principles of scalable distributed systems
  7. Sea shells on the sea shore