Site icon R-bloggers

yorkr pads up for the Twenty20s:Part 3:Overall team performance against all oppositions!

[This article was first published on R – Giga thoughts …, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction

“So in war, the way is to avoid what is strong, and strike at what is weak.”

“Thus the expert in battle moves the enemy, and is not moved by him.”

“Appear weak when you are strong, and strong when you are weak.”

                                         The Art of War - Sun Tzu

This post is a continuation of my 2 earlier posts based on the enhancement of my R package yorkr to includ functions to handle Twenty20 matches. This is the 3rd part of the Twenty20 based functions, the 2 earlier ones were

  1. yorkr pads up for the Twenty20s: Part 1- Analyzing team“s match performance.
  2. yorkr pads up for the Twenty20s: Part 2-Head to head confrontation between teams

This post deals with Class 3 functions, namely the performances of a team in all T20 matches against all oppositions for e.g India/Australia/South Africa against all oppositions in all matches. In other words it is the performance of the team against the rest of the world.

This post has also been published at RPubs [yorkrT20-Part3]http://rpubs.com/tvganesh/yorkrT20-Part3) and can also be downloaded as a PDF document from yorkrT20-Part3.pdf.

You can clone/fork the code for the package yorkr from Github at yorkr-package

The list of functions in Class 3 are

  1. teamBattingScorecardAllOppnAllMatches()
  2. teamBatsmenPartnershipAllOppnAllMatches()
  3. teamBatsmenPartnershipAllOppnAllMatchesPlot()
  4. teamBatsmenVsBowlersAllOppnAllMatchesRept()
  5. teamBatsmenVsBowlersAllOppnAllMatchesPlot()
  6. teamBowlingScorecardAllOppnAllMatchesMain()
  7. teamBowlersVsBatsmenAllOppnAllMatchesRept()
  8. teamBowlersVsBatsmenAllOppnAllMatchesPlot()
  9. teamBowlingWicketKindAllOppnAllMatches()
  10. teamBowlingWicketRunsAllOppnAllMatches()

Note 1: The yorkr package in its current avatar only supports ODI & Twenty20 matches. I will be upgrading the package to handle IPL in the months to come.

Note 2: As in the previous parts the plots usually have the plot=TRUE/FALSE parameter. This is to allow the user to get a return value of the desired dataframe. The user can choose to plot this, in any way he/she likes for e.g in interactive charts using rcharts, ggvis,googleVis,plotly etc

1. Install the package from CRAN

The yorkr package can be installed directly from CRAN now! Install the yorkr package.

if (!require("yorkr")) {
  install.packages("yorkr") 
  library("yorkr")
}
rm(list=ls())

2. Get data for all matches against all oppositions for a team

We can get all matches against all oppositions for a team/country using the function below. The dir parameter should point to the folder in which the RData files where the individual T20 matches exist. This function creates a data frame of all the matches and also saves the resulting dataframe as RData

setwd("C:/software/cricket-package/york-test/yorkrData/Twenty20/T20-team-allmatches-allOppositions")

# Get all matches against all oppositions for India and save as RData
matches <-getAllMatchesAllOpposition("India",dir=".",save=TRUE)
dim(matches)
## [1] 14380    25

“`

3. Save data for all matches against all oppositions

This can be done locally using the function below. This function gets all the T20 matches of the country/team against all other countrioes//teams and combines them into a single dataframe and saves it in the current folder. The current implementation expects that the the RData files of individual matches are in ../data folder. Since I already have converted this I will not be running this again

#saveAllMatchesAllOpposition()

4. Load data directly for all matches between 2 teams

As in my earlier posts (yorkr-Part1 & yorkr-Part2) I have however already saved the data, for all matches of the individual countries, against all oppositons. The data for these matches for the individual teams/countries can be downloaded directly from Github folder at T20-team-allmatches-allOppositions

Note: The dataframe for the different for all the matches of a country against all oppositons can be loaded directly into your code.Feel free to download the zip of the data and to perform any data mining on them.

If you do come up with interesting insights, I would appreciate if attribute the source to Cricsheet(http://cricsheet.org), and my package yorkr and my blog Giga thoughts, besides dropping me a note.*

As in my earlier post I will be directly loading the saved files. For the illustration of the functions, I will use India in all the functions, (for obvious reasons) and will randomly use the data from the rest of the top 8 teams

setwd("C:/software/cricket-package/york-test/yorkrData/Twenty20/T20-team-allmatches-allOppositions")
load("allMatchesAllOpposition-India.RData")
ind_matches <- matches
load("allMatchesAllOpposition-Australia.RData")
aus_matches <- matches
load("allMatchesAllOpposition-New Zealand.RData")
nz_matches <- matches
load("allMatchesAllOpposition-Pakistan.RData")
pak_matches <- matches
load("allMatchesAllOpposition-England.RData")
eng_matches <- matches
load("allMatchesAllOpposition-Sri Lanka.RData")
sl_matches <- matches
load("allMatchesAllOpposition-West Indies.RData")
wi_matches <- matches
load("allMatchesAllOpposition-South Africa.RData")
sa_matches <- matches

5. Team T20 Batting Scorecard (all matches with opposition)

The following functions shows the batting scorecards in each country. It returns a dataframe with the top batsmen in each country

#Top Twenty20 performers for India
m <-teamBattingScorecardAllOppnAllMatches(ind_matches,theTeam="India")
## Total= 8663
m
## Source: local data frame [46 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1       V Kohli         882   124    27  1215
## 2      SK Raina         806   102    39  1114
## 3     RG Sharma         800    91    37  1053
## 4  Yuvraj Singh         656    59    60   933
## 5     G Gambhir         739   110    10   911
## 6      MS Dhoni         723    60    24   864
## 7      V Sehwag         228    36    13   330
## 8     AM Rahane         256    28     6   302
## 9    RV Uthappa         204    26     6   249
## 10     S Dhawan         193    28     8   248
## ..          ...         ...   ...   ...   ...
#Top Twenty20 batsmen for Australia
m <-teamBattingScorecardAllOppnAllMatches(aus_matches,theTeam="Australia")
## Total= 11743
m
## Source: local data frame [70 x 5]
## 
##       batsman ballsPlayed fours sixes  runs
##        (fctr)       (int) (int) (int) (dbl)
## 1   DA Warner        1030   139    67  1465
## 2   SR Watson         888   103    76  1315
## 3    CL White         726    71    44   984
## 4    AJ Finch         566    95    36   874
## 5   DJ Hussey         615    41    34   756
## 6  MEK Hussey         518    58    25   721
## 7   MJ Clarke         467    29    10   488
## 8   GJ Bailey         331    37    20   470
## 9   BJ Haddin         342    30    13   402
## 10 RT Ponting         294    42    11   401
## ..        ...         ...   ...   ...   ...
#Top Twenty20 batsmen for Pakistan
m <-teamBattingScorecardAllOppnAllMatches(pak_matches,theTeam="Pakistan")
## Total= 12943
m
## Source: local data frame [58 x 5]
## 
##            batsman ballsPlayed fours sixes  runs
##             (fctr)       (int) (int) (int) (dbl)
## 1       Umar Akmal        1184   112    48  1506
## 2  Mohammad Hafeez        1254   156    36  1466
## 3    Shahid Afridi         812    89    63  1255
## 4     Shoaib Malik        1068   101    23  1206
## 5    Ahmed Shehzad         799   102    24   941
## 6     Kamran Akmal         705    88    27   871
## 7    Misbah-ul-Haq         685    46    26   770
## 8      Imran Nazir         338    55    21   468
## 9      Salman Butt         410    58     6   467
## 10     Younis Khan         331    32    12   427
## ..             ...         ...   ...   ...   ...
#Top Twenty20 batsmen for New Zealand
m <-teamBattingScorecardAllOppnAllMatches(nz_matches,theTeam="New Zealand")
## Total= 11656
m
## Source: local data frame [62 x 5]
## 
##          batsman ballsPlayed fours sixes  runs
##           (fctr)       (int) (int) (int) (dbl)
## 1    BB McCullum        1501   199    89  2106
## 2     MJ Guptill        1259   155    68  1665
## 3    LRPL Taylor         900    76    45  1126
## 4  KS Williamson         650   101    10   844
## 5      SB Styris         443    38    25   554
## 6   JEC Franklin         371    28    23   463
## 7       JDP Oram         318    37    20   451
## 8       JD Ryder         336    45    16   434
## 9        C Munro         227    23    27   377
## 10      RJ Nicol         283    33    11   327
## ..           ...         ...   ...   ...   ...
#Top Twenty20 batsmen for England
m <-teamBattingScorecardAllOppnAllMatches(eng_matches,theTeam="England")
## Total= 11215
m
## Source: local data frame [65 x 5]
## 
##           batsman ballsPlayed fours sixes  runs
##            (fctr)       (int) (int) (int) (dbl)
## 1      EJG Morgan         938   108    53  1285
## 2    KP Pietersen         810   119    32  1176
## 3        AD Hales         790   116    35  1111
## 4       LJ Wright         540    68    31   759
## 5       RS Bopara         588    54    17   711
## 6  PD Collingwood         451    38    24   583
## 7      JC Buttler         410    43    23   562
## 8         MJ Lumb         394    64    21   552
## 9    C Kieswetter         456    47    23   526
## 10        OA Shah         276    26    13   347
## ..            ...         ...   ...   ...   ...
#Top Twenty20 batsmen for West Indies
m <-teamBattingScorecardAllOppnAllMatches(wi_matches,theTeam="West Indies")
## Total= 9292
m
## Source: local data frame [54 x 5]
## 
##          batsman ballsPlayed fours sixes  runs
##           (fctr)       (int) (int) (int) (dbl)
## 1       CH Gayle         958   122    87  1406
## 2       DJ Bravo         792    57    43   979
## 3     MN Samuels         764    76    46   952
## 4    LMP Simmons         633    68    25   732
## 5     KA Pollard         453    50    36   664
## 6       DR Smith         463    62    31   582
## 7      DJG Sammy         330    43    27   526
## 8      J Charles         382    59    12   456
## 9   ADS Fletcher         341    26    19   387
## 10 S Chanderpaul         337    34     5   343
## ..           ...         ...   ...   ...   ...
#Top Twenty20 batsmen for Sri Lanka
m <-teamBattingScorecardAllOppnAllMatches(sl_matches,theTeam="Sri Lanka")
## Total= 9572
m
## Source: local data frame [54 x 5]
## 
##             batsman ballsPlayed fours sixes  runs
##              (fctr)       (int) (int) (int) (dbl)
## 1        TM Dilshan        1235   186    26  1556
## 2  DPMD Jayawardene        1005   157    28  1346
## 3     KC Sangakkara        1088   132    18  1320
## 4        AD Mathews         640    54    24   794
## 5       MDKJ Perera         435    60    23   596
## 6     ST Jayasuriya         428    70    21   581
## 7       NLTC Perera         310    38    22   480
## 8     CK Kapugedera         329    36    16   417
## 9      LD Chandimal         371    31     7   380
## 10  HDRL Thirimanne         240    26     5   277
## ..              ...         ...   ...   ...   ...

6. Team Batting Scorecard in Twenty20 matches against all oppositions

The following functions show the best batsmen from the opposition ‘theTeam’ in the ‘matches’. For e.g. when the matches=ind_matches and theTeam=“England” then the returned dataframe shows the best English batsmen against India

#Top T20 England batsmen against India
m <-teamBattingScorecardAllOppnAllMatches(matches=ind_matches,theTeam="England")
## Total= 1169
m
## Source: local data frame [26 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1    EJG Morgan          96    15    10   176
## 2  KP Pietersen         107    18     5   171
## 3      AD Hales         112    14     6   149
## 4     RS Bopara          94     9     2   103
## 5      SR Patel          73     6     2    79
## 6    JC Buttler          54     2     4    69
## 7  C Kieswetter          47     8     3    65
## 8     LJ Wright          50     4     3    62
## 9       MJ Lumb          39     6     2    51
## 10   VS Solanki          30     5     1    43
## ..          ...         ...   ...   ...   ...
#Top T20 Australian batsmen against India
m <-teamBattingScorecardAllOppnAllMatches(matches=ind_matches,theTeam="Australia")
## Total= 1767
m
## Source: local data frame [40 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1     SR Watson         173    16    20   284
## 2      AJ Finch         164    33     5   249
## 3     DA Warner         134    14    14   204
## 4       MS Wade          93     6     5   125
## 5     DJ Hussey          81     5     6   101
## 6     ML Hayden          63     5     6    79
## 7    RT Ponting          52    13    NA    76
## 8     MJ Clarke          54     3     1    65
## 9     A Symonds          43     4     2    63
## 10 AC Gilchrist          38     7     3    59
## ..          ...         ...   ...   ...   ...
#Top T20 New Zealand batsmen against Australia
m <-teamBattingScorecardAllOppnAllMatches(aus_matches,theTeam="New Zealand")
## Total= 727
m
## Source: local data frame [27 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1   BB McCullum         138    22    12   228
## 2     SB Styris          54     9     3    84
## 3      JDP Oram          34     5     6    67
## 4    GJ Hopkins          30     5     3    57
## 5  JEC Franklin          52     3     2    53
## 6    MJ Guptill          47     7    NA    47
## 7      NT Broom          26     6    NA    36
## 8   NL McCullum          13     2     2    25
## 9    GD Elliott          26     2    NA    23
## 10   SP Fleming          13     3    NA    18
## ..          ...         ...   ...   ...   ...
#Top T20 Sri Lankan batsmen against West Indies
m <-teamBattingScorecardAllOppnAllMatches(wi_matches,theTeam="Sri Lanka")
## Total= 1225
m
## Source: local data frame [21 x 5]
## 
##             batsman ballsPlayed fours sixes  runs
##              (fctr)       (int) (int) (int) (dbl)
## 1        TM Dilshan         224    42     4   334
## 2  DPMD Jayawardene         149    21     5   202
## 3     KC Sangakkara         119    12     3   135
## 4     ST Jayasuriya          91    14     3   111
## 5        AD Mathews          52     6     7    98
## 6       MDKJ Perera          52    10     3    78
## 7  DSNFG Jayasuriya          52     5     3    66
## 8   HDRL Thirimanne          42     3     2    48
## 9      LD Chandimal          20     4     2    41
## 10  KMDN Kulasekara          18     3     1    30
## ..              ...         ...   ...   ...   ...

7. Team Batting Partnerships in Twenty20 matches against all oppositions

This gives the top batting partnerships in each team in all its matches against all oppositions. The report can either be a ‘summary’ or a ‘detailed’ breakup of the batting partnerships.

# The function gives the names of highest T20 partnership for India. The default report parameter is "summary"
m <- teamBatsmenPartnershipAllOppnAllMatches(ind_matches,theTeam='India')
m
## Source: local data frame [46 x 2]
## 
##         batsman totalRuns
##          (fctr)     (dbl)
## 1       V Kohli      1215
## 2      SK Raina      1114
## 3     RG Sharma      1053
## 4  Yuvraj Singh       933
## 5     G Gambhir       911
## 6      MS Dhoni       864
## 7      V Sehwag       330
## 8     AM Rahane       302
## 9    RV Uthappa       249
## 10     S Dhawan       248
## ..          ...       ...
# When the report parameter is 'detailed' then the detailed break up of the T20 partnership is returned as a data frame
m <- teamBatsmenPartnershipAllOppnAllMatches(matches,theTeam='India',report="detailed")
head(m,30)
##      batsman      nonStriker partnershipRuns totalRuns
## 1  RG Sharma       G Gambhir              26       309
## 2  RG Sharma        SK Raina              25       309
## 3  RG Sharma    Yuvraj Singh              41       309
## 4  RG Sharma        MS Dhoni              31       309
## 5  RG Sharma        V Sehwag               0       309
## 6  RG Sharma         V Kohli             110       309
## 7  RG Sharma       AM Rahane              24       309
## 8  RG Sharma        S Dhawan              33       309
## 9  RG Sharma      RV Uthappa              13       309
## 10 RG Sharma       IK Pathan               6       309
## 11  SK Raina       RG Sharma              37       250
## 12  SK Raina    Yuvraj Singh              50       250
## 13  SK Raina        MS Dhoni              73       250
## 14  SK Raina       YK Pathan              51       250
## 15  SK Raina      KD Karthik              16       250
## 16  SK Raina         V Kohli              21       250
## 17  SK Raina        AR Patel               0       250
## 18  SK Raina       AT Rayudu               2       250
## 19   V Kohli       RG Sharma              70       146
## 20   V Kohli        SK Raina              11       146
## 21   V Kohli    Yuvraj Singh              37       146
## 22   V Kohli        MS Dhoni               9       146
## 23   V Kohli         M Vijay               2       146
## 24   V Kohli        V Sehwag               2       146
## 25   V Kohli       AM Rahane              15       146
## 26  MS Dhoni       RG Sharma              45       124
## 27  MS Dhoni        SK Raina              53       124
## 28  MS Dhoni    Yuvraj Singh               5       124
## 29  MS Dhoni Harbhajan Singh               8       124
## 30  MS Dhoni         V Kohli               0       124

9. More Team Batting Partnerships in Twenty20 matches against all oppositions

When we use the dataframe ind_matches (matches of India against all opoositions) and choose another country in the theTeam then we will get the names of those top batsmen against India.

# Top T20 England batting partnerships against India (report="summary")
m <- teamBatsmenPartnershipAllOppnAllMatches(ind_matches,theTeam='England')
m
## Source: local data frame [26 x 2]
## 
##         batsman totalRuns
##          (fctr)     (dbl)
## 1    EJG Morgan       176
## 2  KP Pietersen       171
## 3      AD Hales       149
## 4     RS Bopara       103
## 5      SR Patel        79
## 6    JC Buttler        69
## 7  C Kieswetter        65
## 8     LJ Wright        62
## 9       MJ Lumb        51
## 10   VS Solanki        43
## ..          ...       ...
# Top T20 South Africa  batting partnerships against India (report="detailed")
m <- teamBatsmenPartnershipAllOppnAllMatches(ind_matches,theTeam='South Africa', report="detailed")
m[1:30,]
##           batsman      nonStriker partnershipRuns totalRuns
## 1  AB de Villiers        GC Smith              28       208
## 2  AB de Villiers       JP Duminy              40       208
## 3  AB de Villiers      MV Boucher              19       208
## 4  AB de Villiers       JA Morkel              11       208
## 5  AB de Villiers       JH Kallis              17       208
## 6  AB de Villiers    F du Plessis              24       208
## 7  AB de Villiers         HM Amla              49       208
## 8  AB de Villiers         JM Kemp               6       208
## 9  AB de Villiers      MN van Wyk              14       208
## 10      JP Duminy  AB de Villiers              20       173
## 11      JP Duminy      MV Boucher               4       173
## 12      JP Duminy    F du Plessis              33       173
## 13      JP Duminy     F Behardien              88       173
## 14      JP Duminy       DA Miller              28       173
## 15      JP Duminy      MN van Wyk               0       173
## 16   F du Plessis  AB de Villiers              45       143
## 17   F du Plessis       JP Duminy              86       143
## 18   F du Plessis         HM Amla              12       143
## 19      JH Kallis        GC Smith              59       140
## 20      JH Kallis  AB de Villiers               8       140
## 21      JH Kallis       LE Bosman              12       140
## 22      JH Kallis       CA Ingram              59       140
## 23      JH Kallis         RE Levi               2       140
## 24      JA Morkel  AB de Villiers              12       109
## 25      JA Morkel      MV Boucher              34       109
## 26      JA Morkel         J Botha               8       109
## 27      JA Morkel     F Behardien              16       109
## 28      JA Morkel        DW Steyn               7       109
## 29      JA Morkel         JM Kemp               3       109
## 30      JA Morkel JJ van der Wath              28       109

10. Team Batting partnerships of other countries in Twenty20 matches against all oppositions

#Top Indian T20 batting partnerships  against England matches
m <- teamBatsmenPartnershipAllOppnAllMatches(eng_matches,theTeam='India',report="detailed")
head(m,30)
##      batsman   nonStriker partnershipRuns totalRuns
## 1    V Kohli    G Gambhir              78       184
## 2    V Kohli   RV Uthappa               4       184
## 3    V Kohli Yuvraj Singh              10       184
## 4    V Kohli    RG Sharma               2       184
## 5    V Kohli     SK Raina              42       184
## 6    V Kohli    AM Rahane               3       184
## 7    V Kohli     S Dhawan              45       184
## 8   MS Dhoni   RV Uthappa               5       167
## 9   MS Dhoni Yuvraj Singh               4       167
## 10  MS Dhoni    IK Pathan               2       167
## 11  MS Dhoni    RG Sharma               9       167
## 12  MS Dhoni     SK Raina              71       167
## 13  MS Dhoni    RA Jadeja              11       167
## 14  MS Dhoni    YK Pathan              36       167
## 15  MS Dhoni    AT Rayudu              18       167
## 16  MS Dhoni     R Ashwin              11       167
## 17 G Gambhir     V Sehwag              51       162
## 18 G Gambhir   RV Uthappa               7       162
## 19 G Gambhir Yuvraj Singh               2       162
## 20 G Gambhir    IK Pathan              11       162
## 21 G Gambhir    RG Sharma              25       162
## 22 G Gambhir     SK Raina              10       162
## 23 G Gambhir    RA Jadeja              15       162
## 24 G Gambhir    AM Rahane              18       162
## 25 G Gambhir      V Kohli              23       162
## 26  SK Raina    G Gambhir               2       161
## 27  SK Raina     MS Dhoni              80       161
## 28  SK Raina    RG Sharma              16       161
## 29  SK Raina      V Kohli              34       161
## 30  SK Raina      P Kumar               0       161
#Top South Africa T20 batting partnerships 
m <- teamBatsmenPartnershipAllOppnAllMatches(sa_matches,theTeam='South Africa', report="detailed")
head(m,30)
##           batsman       nonStriker partnershipRuns totalRuns
## 1       JP Duminy        LE Bosman               3      1528
## 2       JP Duminy         GC Smith              78      1528
## 3       JP Duminy        JH Kallis              77      1528
## 4       JP Duminy   AB de Villiers             207      1528
## 5       JP Duminy       MV Boucher              93      1528
## 6       JP Duminy        JA Morkel             143      1528
## 7       JP Duminy RE van der Merwe              12      1528
## 8       JP Duminy         DW Steyn              10      1528
## 9       JP Duminy          J Botha              34      1528
## 10      JP Duminy VB van Jaarsveld              50      1528
## 11      JP Duminy         HH Gibbs               0      1528
## 12      JP Duminy          HM Amla             104      1528
## 13      JP Duminy      ND McKenzie              20      1528
## 14      JP Duminy      F Behardien             117      1528
## 15      JP Duminy      RJ Peterson              32      1528
## 16      JP Duminy        Q de Kock              13      1528
## 17      JP Duminy        DA Miller             284      1528
## 18      JP Duminy     RR Hendricks              15      1528
## 19      JP Duminy        R McLaren               1      1528
## 20      JP Duminy       WD Parnell               5      1528
## 21      JP Duminy          D Wiese               6      1528
## 22      JP Duminy     F du Plessis             119      1528
## 23      JP Duminy        JL Ontong              17      1528
## 24      JP Duminy        CA Ingram              67      1528
## 25      JP Duminy          HG Kuhn               6      1528
## 26      JP Duminy       MN van Wyk               7      1528
## 27      JP Duminy      AN Petersen               8      1528
## 28 AB de Villiers         GC Smith              72      1167
## 29 AB de Villiers        JH Kallis              81      1167
## 30 AB de Villiers        JP Duminy             263      1167
#Top Sri Lanka T20 batting partnerships 
m <- teamBatsmenPartnershipAllOppnAllMatches(sl_matches,theTeam='Sri Lanka',report="summary")
m
## Source: local data frame [54 x 2]
## 
##             batsman totalRuns
##              (fctr)     (dbl)
## 1        TM Dilshan      1556
## 2  DPMD Jayawardene      1346
## 3     KC Sangakkara      1320
## 4        AD Mathews       794
## 5       MDKJ Perera       596
## 6     ST Jayasuriya       581
## 7       NLTC Perera       480
## 8     CK Kapugedera       417
## 9      LD Chandimal       380
## 10  HDRL Thirimanne       277
## ..              ...       ...
#Top England T20 batting partnerships 
m <- teamBatsmenPartnershipAllOppnAllMatches(eng_matches,theTeam='England',report="summary")
m
## Source: local data frame [65 x 2]
## 
##           batsman totalRuns
##            (fctr)     (dbl)
## 1      EJG Morgan      1285
## 2    KP Pietersen      1176
## 3        AD Hales      1111
## 4       LJ Wright       759
## 5       RS Bopara       711
## 6  PD Collingwood       583
## 7      JC Buttler       562
## 8         MJ Lumb       552
## 9    C Kieswetter       526
## 10        OA Shah       347
## ..            ...       ...
#Top Australian T20 batting partnerships in West Indian matches
m <- teamBatsmenPartnershipAllOppnAllMatches(wi_matches,theTeam='Australia',report="summary")
m
## Source: local data frame [31 x 2]
## 
##       batsman totalRuns
##        (fctr)     (dbl)
## 1   DA Warner       311
## 2   SR Watson       240
## 3  MEK Hussey       147
## 4   BJ Haddin       146
## 5   GJ Bailey       135
## 6   DJ Hussey        57
## 7    AC Voges        51
## 8    SE Marsh        50
## 9  GJ Maxwell        45
## 10   L Ronchi        36
## ..        ...       ...
#Top England T20 batting partnerships in New Zealand  matches
m <- teamBatsmenPartnershipAllOppnAllMatches(nz_matches,theTeam='England',report="summary")
m
## Source: local data frame [35 x 2]
## 
##           batsman totalRuns
##            (fctr)     (dbl)
## 1       LJ Wright       273
## 2        AD Hales       194
## 3         MJ Lumb       188
## 4      EJG Morgan       152
## 5      JC Buttler       140
## 6    KP Pietersen       112
## 7         OA Shah        91
## 8  PD Collingwood        86
## 9         IR Bell        73
## 10        JE Root        68
## ..            ...       ...

11. Team Batting Partnership plots in Twenty20 matches against all oppositions

Graphical plot of batting partnerships for the countries

# Plot of T20 batting partnerships of India (Virat Kohli and Suresh Raina have the best T20 partnerships)
teamBatsmenPartnershipAllOppnAllMatchesPlot(ind_matches,"India",main="India")

# Plot of T20 batting partnerships of Pakistan (Umar Akmal and Mohammed Hafeez lead)
teamBatsmenPartnershipAllOppnAllMatchesPlot(pak_matches,"Pakistan",main="Pakistan")

# Plot of T20 batting partnerships of Australia (David Warner and Shane Watson head the list)
teamBatsmenPartnershipAllOppnAllMatchesPlot(aus_matches,"Australia",main="Australia")

12. Top opposition batting partnerships in Twenty20 matches against all oppositions

This gives the best performance of the team against a specified country

# Top India T20 partnerships against West Indies
teamBatsmenPartnershipAllOppnAllMatchesPlot(ind_matches,"India",main="West Indies")

# Top Sri Lanka T20 partnerships against India
teamBatsmenPartnershipAllOppnAllMatchesPlot(sl_matches,"Sri Lanka",main="India")

# Top New Zealand T20 partnerships against South Africa
teamBatsmenPartnershipAllOppnAllMatchesPlot(nz_matches,"New Zealand",main="South Africa")

13. Batsmen vs Bowlers in Twenty20 matches against all oppositions

The function below gives the top performance of batsmen against the opposition countries

# Top T20 batsmen against bowlers when rank=0
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"India",rank=0)
m
## Source: local data frame [46 x 2]
## 
##         batsman runsScored
##          (fctr)      (dbl)
## 1       V Kohli       1215
## 2      SK Raina       1114
## 3     RG Sharma       1053
## 4  Yuvraj Singh        933
## 5     G Gambhir        911
## 6      MS Dhoni        864
## 7      V Sehwag        330
## 8     AM Rahane        302
## 9    RV Uthappa        249
## 10     S Dhawan        248
## ..          ...        ...
# Performance of India batsman in T20 with rank=1 against international bowlers and runs scored against bowlers. This is Virat Kohli for India
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"India",rank=1,dispRows=30)
m
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##    batsman        bowler  runs
##     (fctr)        (fctr) (dbl)
## 1  V Kohli Shahid Afridi    43
## 2  V Kohli     SR Watson    39
## 3  V Kohli   Imran Tahir    34
## 4  V Kohli      CJ Boyce    32
## 5  V Kohli   Saeed Ajmal    32
## 6  V Kohli        AJ Tye    31
## 7  V Kohli  HMRKB Herath    29
## 8  V Kohli    TT Bresnan    28
## 9  V Kohli KW Richardson    27
## 10 V Kohli     SM Boland    27
## ..     ...           ...   ...
# Performance of India batsman in T20 with rank=2 against international bowlers and runs scored against these bowlers. This is Suresh Raina for India
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"India",rank=2,dispRows=50)
m
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##     batsman        bowler  runs
##      (fctr)        (fctr) (dbl)
## 1  SK Raina RK Kleinveldt    33
## 2  SK Raina     JH Kallis    31
## 3  SK Raina    T Thushara    31
## 4  SK Raina        AJ Tye    29
## 5  SK Raina    TT Bresnan    29
## 6  SK Raina     SR Watson    26
## 7  SK Raina   JC Tredwell    26
## 8  SK Raina    IE O'Brien    26
## 9  SK Raina Mohammad Nabi    22
## 10 SK Raina      GP Swann    22
## ..      ...           ...   ...
# Performance of England batsman in T20 with rank=1 against international bowlers and runs scored against these bowlers. This returns a data frame of the the theTeam's batsmen against the bowlers for which the 'matches' dataframe is used. This Is EJG Morgan of England,
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(matches=ind_matches,theTeam="England",rank=1,dispRows=25)
m
## Source: local data frame [15 x 3]
## Groups: batsman [1]
## 
##       batsman          bowler  runs
##        (fctr)          (fctr) (dbl)
## 1  EJG Morgan        R Ashwin    24
## 2  EJG Morgan        AB Dinda    22
## 3  EJG Morgan       KV Sharma    18
## 4  EJG Morgan       RA Jadeja    17
## 5  EJG Morgan       MM Sharma    16
## 6  EJG Morgan       RG Sharma    15
## 7  EJG Morgan         V Kohli    14
## 8  EJG Morgan  Mohammed Shami    13
## 9  EJG Morgan    Yuvraj Singh    11
## 10 EJG Morgan         P Kumar    10
## 11 EJG Morgan       PP Chawla     7
## 12 EJG Morgan         P Awana     7
## 13 EJG Morgan       IK Pathan     1
## 14 EJG Morgan        MM Patel     1
## 15 EJG Morgan Harbhajan Singh     0
# All the top T20 Australian batsmen against India in all of Indian matches
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"Australia",rank=0)
m
## Source: local data frame [40 x 2]
## 
##         batsman runsScored
##          (fctr)      (dbl)
## 1     SR Watson        284
## 2      AJ Finch        249
## 3     DA Warner        204
## 4       MS Wade        125
## 5     DJ Hussey        101
## 6     ML Hayden         79
## 7    RT Ponting         76
## 8     MJ Clarke         65
## 9     A Symonds         63
## 10 AC Gilchrist         59
## ..          ...        ...

14. Batsmen vs Bowlers in Twenty20 matches against all oppositions (continued)

# The best India T20 batsman(rank=0) against England and his performance against England bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(eng_matches,"India",rank=1,dispRows=30)
m
## Source: local data frame [13 x 3]
## Groups: batsman [1]
## 
##    batsman      bowler  runs
##     (fctr)      (fctr) (dbl)
## 1  V Kohli  TT Bresnan    28
## 2  V Kohli   LJ Wright    26
## 3  V Kohli   CR Woakes    25
## 4  V Kohli JC Tredwell    21
## 5  V Kohli     ST Finn    17
## 6  V Kohli      MM Ali    15
## 7  V Kohli   SCJ Broad    14
## 8  V Kohli JW Dernbach    10
## 9  V Kohli   RS Bopara     9
## 10 V Kohli   SC Meaker     7
## 11 V Kohli   HF Gurney     6
## 12 V Kohli    GP Swann     5
## 13 V Kohli   DR Briggs     1
# All the top Sri Lanka T20 batsmen (rank=0) against Australia and performances against Australian bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(aus_matches,"Sri Lanka",rank=0)
m
## Source: local data frame [24 x 2]
## 
##             batsman runsScored
##              (fctr)      (dbl)
## 1        TM Dilshan        247
## 2  DPMD Jayawardene        209
## 3     KC Sangakkara        177
## 4       NLTC Perera         80
## 5      LD Chandimal         55
## 6       BMAJ Mendis         55
## 7         J Mubarak         49
## 8        AD Mathews         48
## 9       MDKJ Perera         48
## 10       WPUJC Vaas         21
## ..              ...        ...
#All the top England T20 batsmen (rank=0) and their performances against South African bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(sa_matches,"England",rank=0)
m
## Source: local data frame [30 x 2]
## 
##           batsman runsScored
##            (fctr)      (dbl)
## 1      EJG Morgan        145
## 2    C Kieswetter        117
## 3    KP Pietersen        116
## 4  PD Collingwood         90
## 5       IJL Trott         84
## 6         OA Shah         74
## 7      JC Buttler         72
## 8        AD Hales         60
## 9        MJ Prior         42
## 10      RS Bopara         39
## ..            ...        ...

15. Batsmen vs Bowlers Plot in Twenty20 matches against all oppositions

The following functions plot the performances of the batsman based on the rank chosen against opposition bowlers. Note: The rank has to be >0

#The following plot displays the performance of the top India T20 batsman (rank=1) against all opposition bowlers. This is Virat Kohli for India

d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"India",rank=1,dispRows=50)
d
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##    batsman        bowler  runs
##     (fctr)        (fctr) (dbl)
## 1  V Kohli Shahid Afridi    43
## 2  V Kohli     SR Watson    39
## 3  V Kohli   Imran Tahir    34
## 4  V Kohli      CJ Boyce    32
## 5  V Kohli   Saeed Ajmal    32
## 6  V Kohli        AJ Tye    31
## 7  V Kohli  HMRKB Herath    29
## 8  V Kohli    TT Bresnan    28
## 9  V Kohli KW Richardson    27
## 10 V Kohli     SM Boland    27
## ..     ...           ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

e <- teamBatsmenVsBowlersAllOppnAllMatchesPlot(d,plot=FALSE)
e
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##    batsman        bowler  runs
##     (fctr)        (fctr) (dbl)
## 1  V Kohli Shahid Afridi    43
## 2  V Kohli     SR Watson    39
## 3  V Kohli   Imran Tahir    34
## 4  V Kohli      CJ Boyce    32
## 5  V Kohli   Saeed Ajmal    32
## 6  V Kohli        AJ Tye    31
## 7  V Kohli  HMRKB Herath    29
## 8  V Kohli    TT Bresnan    28
## 9  V Kohli KW Richardson    27
## 10 V Kohli     SM Boland    27
## ..     ...           ...   ...
# The following plot displays the performance of the T20 batsman (rank=2) against all opposition bowlers. This is M S Dhoni for India
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"India",rank=2,dispRows=50)
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

# Best T20 batsman of South Africa against Indian  bowlers
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(ind_matches,"South Africa",rank=1,dispRows=30)
d
## Source: local data frame [21 x 3]
## Groups: batsman [1]
## 
##           batsman          bowler  runs
##            (fctr)          (fctr) (dbl)
## 1  AB de Villiers    Yuvraj Singh    27
## 2  AB de Villiers        R Ashwin    21
## 3  AB de Villiers       S Aravind    18
## 4  AB de Villiers        RP Singh    14
## 5  AB de Villiers Harbhajan Singh    13
## 6  AB de Villiers         B Kumar    13
## 7  AB de Villiers       MM Sharma    12
## 8  AB de Villiers       RA Jadeja    11
## 9  AB de Villiers       YK Pathan    11
## 10 AB de Villiers          Z Khan     9
## ..            ...             ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

# Best T20 batsman of England (rank=1) against Indian bowlers (matches=ind_matches)
d <-teamBatsmenVsBowlersAllOppnAllMatchesRept(matches=ind_matches,"England",rank=1,dispRows=50)
d
## Source: local data frame [15 x 3]
## Groups: batsman [1]
## 
##       batsman          bowler  runs
##        (fctr)          (fctr) (dbl)
## 1  EJG Morgan        R Ashwin    24
## 2  EJG Morgan        AB Dinda    22
## 3  EJG Morgan       KV Sharma    18
## 4  EJG Morgan       RA Jadeja    17
## 5  EJG Morgan       MM Sharma    16
## 6  EJG Morgan       RG Sharma    15
## 7  EJG Morgan         V Kohli    14
## 8  EJG Morgan  Mohammed Shami    13
## 9  EJG Morgan    Yuvraj Singh    11
## 10 EJG Morgan         P Kumar    10
## 11 EJG Morgan       PP Chawla     7
## 12 EJG Morgan         P Awana     7
## 13 EJG Morgan       IK Pathan     1
## 14 EJG Morgan        MM Patel     1
## 15 EJG Morgan Harbhajan Singh     0
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

15. Batsmen vs Bowlers Plot in Twenty20 matches against all oppositions (continued)

# Top T20 batsman of South Africa and performance against opposition bowlers of all countries
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(sa_matches,"South Africa",rank=1,dispRows=50)
d
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##      batsman        bowler  runs
##       (fctr)        (fctr) (dbl)
## 1  JP Duminy   Saeed Ajmal    63
## 2  JP Duminy    BAW Mendis    63
## 3  JP Duminy      JR Hopes    58
## 4  JP Duminy     DJ Hussey    48
## 5  JP Duminy      KD Mills    46
## 6  JP Duminy    TG Southee    43
## 7  JP Duminy      CB Mpofu    42
## 8  JP Duminy Shahid Afridi    40
## 9  JP Duminy       SW Tait    38
## 10 JP Duminy   NL McCullum    32
## ..       ...           ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

# Do not display plot but return dataframe
e <- teamBatsmenVsBowlersAllOppnAllMatchesPlot(d,plot=FALSE)
e
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##      batsman        bowler  runs
##       (fctr)        (fctr) (dbl)
## 1  JP Duminy   Saeed Ajmal    63
## 2  JP Duminy    BAW Mendis    63
## 3  JP Duminy      JR Hopes    58
## 4  JP Duminy     DJ Hussey    48
## 5  JP Duminy      KD Mills    46
## 6  JP Duminy    TG Southee    43
## 7  JP Duminy      CB Mpofu    42
## 8  JP Duminy Shahid Afridi    40
## 9  JP Duminy       SW Tait    38
## 10 JP Duminy   NL McCullum    32
## ..       ...           ...   ...
# Top T20 batsman of Sri Lanka against bowlers of all countries
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(sl_matches,"Sri Lanka",rank=1,dispRows=50)
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

# Best T20 West Indian against English bowlrs
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(eng_matches,"West Indies",rank=1,dispRows=50)
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

16 Team bowling T20 scorecard against all opposition

The functions lists the top T20 bowlers of each country in matches. This function returns a dataframe when ‘matches’ is the matches of the country and ‘theTeam’ is the same country as in the functions below

teamBowlingScorecardAllOppnAllMatchesMain(matches=ind_matches,theTeam="India")
## Source: local data frame [41 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1         R Ashwin    18       0   900      41
## 2        IK Pathan    16       0   618      29
## 3  Harbhajan Singh    18       0   622      27
## 4     Yuvraj Singh    13       0   418      24
## 5        RA Jadeja    17       0   635      23
## 6          A Nehra    11       0   373      22
## 7         RP Singh     8       0   225      19
## 8           Z Khan    16       0   448      18
## 9         AB Dinda    11       0   245      17
## 10         B Kumar     9       0   294      14
## ..             ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(matches=aus_matches,theTeam="Australia")
## Source: local data frame [56 x 5]
## 
##        bowler overs maidens  runs wickets
##        (fctr) (int)   (int) (dbl)   (dbl)
## 1   SR Watson    21       0  1062      49
## 2  MG Johnson    19       0   797      42
## 3       B Lee    13       0   714      30
## 4     SW Tait    15       0   589      30
## 5   DP Nannes    14       0   403      29
## 6    MA Starc    18       0   508      28
## 7  PJ Cummins    19       0   395      22
## 8  NW Bracken    12       0   438      21
## 9   DJ Hussey    13       1   392      21
## 10  SPD Smith    10       0   377      18
## ..        ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(eng_matches,"England")
## Source: local data frame [47 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1       SCJ Broad    21       0  1491      68
## 2        GP Swann    16       0   859      53
## 3     JW Dernbach    17       0  1020      45
## 4         ST Finn    16       0   583      30
## 5      TT Bresnan    11       0   887      27
## 6   RJ Sidebottom    13       0   437      26
## 7     JM Anderson    16       0   552      20
## 8       LJ Wright    11       0   465      18
## 9       RS Bopara    12       0   387      17
## 10 PD Collingwood    10       0   329      16
## ..            ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(pak_matches,"Pakistan")
## Source: local data frame [37 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1    Shahid Afridi    16       0  2095      96
## 2      Saeed Ajmal    17       0  1516      94
## 3         Umar Gul    20       0  1400      91
## 4    Sohail Tanvir    18       0  1212      53
## 5  Mohammad Hafeez    19       0  1093      47
## 6    Mohammad Amir    11       0   557      27
## 7     Abdul Razzaq    13       0   367      22
## 8     Shoaib Malik    12       0   435      19
## 9    Shoaib Akhtar    10       0   421      19
## 10      Wahab Riaz    14       1   392      19
## ..             ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(sa_matches,"South Africa")
## Source: local data frame [40 x 5]
## 
##         bowler overs maidens  runs wickets
##         (fctr) (int)   (int) (dbl)   (dbl)
## 1     DW Steyn    17       0   879      59
## 2     M Morkel    18       0  1022      52
## 3   WD Parnell    21       0   891      41
## 4      J Botha    18       0   823      40
## 5    JA Morkel    19       0   835      30
## 6  Imran Tahir    13       0   426      27
## 7  RJ Peterson    18       1   451      26
## 8      D Wiese    16       0   267      22
## 9  LL Tsotsobe    14       0   541      20
## 10   R McLaren    16       0   332      19
## ..         ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(nz_matches,"New Zealand")
## Source: local data frame [48 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1     NL McCullum    18       0  1240      59
## 2      TG Southee    20       0  1182      52
## 3        KD Mills    16       0  1190      49
## 4      DL Vettori    12       0   748      39
## 5       IG Butler    15       0   481      27
## 6  MJ McClenaghan    19       0   642      25
## 7         SE Bond    12       0   518      25
## 8    JEC Franklin    16       0   417      25
## 9        JDP Oram    17       0   793      21
## 10      SB Styris    11       0   349      20
## ..            ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(sl_matches,"Sri Lanka")
## Source: local data frame [42 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1       SL Malinga    19       0  1522      86
## 2       BAW Mendis    17       0   911      61
## 3  KMDN Kulasekara    15       0  1052      52
## 4       AD Mathews    17       0   814      35
## 5      NLTC Perera    17       0   769      35
## 6  SMSM Senanayake    16       0   442      26
## 7    ST Jayasuriya    13       0   415      20
## 8     CRD Fernando    16       0   377      16
## 9     HMRKB Herath    12       2   174      15
## 10  M Muralitharan    13       0   297      14
## ..             ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(wi_matches,"West Indies")
## Source: local data frame [37 x 5]
## 
##        bowler overs maidens  runs wickets
##        (fctr) (int)   (int) (dbl)   (dbl)
## 1   DJG Sammy    20       0  1037      49
## 2    DJ Bravo    18       0  1127      46
## 3   SP Narine    15       0   692      40
## 4    S Badree    11       0   464      34
## 5   R Rampaul    16       0   705      29
## 6   JE Taylor    14       0   529      28
## 7  MN Samuels     6       0   561      24
## 8  KA Pollard    16       0   598      23
## 9  FH Edwards    14       0   497      19
## 10 K Santokie     9       0   278      19
## ..        ...   ...     ...   ...     ...

17 Team bowling T20 scorecard against all opposition (continued)

The function lists the top bowlers of a country (‘matches’) against the opposition country

# Best Indian bowlers in matches against Australia
teamBowlingScorecardAllOppnAllMatches(ind_matches,'Australia')
## Source: local data frame [26 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1         R Ashwin    13       1   232      10
## 2        RA Jadeja     7       0   219       9
## 3        JJ Bumrah     6       0   103       6
## 4    R Vinay Kumar     1       0    79       6
## 5     Yuvraj Singh     3       0    72       5
## 6         R Sharma     1       0    56       5
## 7          A Nehra     5       0   127       4
## 8        IK Pathan     8       0   115       4
## 9          B Kumar     4       0    42       4
## 10 Harbhajan Singh     8       0    83       3
## ..             ...   ...     ...   ...     ...
# Best Australian bowlers in matches against India
teamBowlingScorecardAllOppnAllMatches(aus_matches,'India')
## Source: local data frame [36 x 5]
## 
##        bowler overs maidens  runs wickets
##        (fctr) (int)   (int) (dbl)   (dbl)
## 1   SR Watson    13       0   201      11
## 2  MG Johnson     5       0    54       5
## 3       B Lee     6       0   133       4
## 4     SW Tait     5       0   112       3
## 5  NW Bracken     6       0    68       3
## 6   DP Nannes     1       0    25       3
## 7   DJ Hussey     4       0    24       3
## 8  PJ Cummins     4       0    16       3
## 9    CJ McKay     1       0    75       2
## 10    GB Hogg     5       0    69       2
## ..        ...   ...     ...   ...     ...
# Best New Zealand bowlers in matches against England
teamBowlingScorecardAllOppnAllMatches(nz_matches,'England')
## Source: local data frame [26 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1  MJ McClenaghan     9       0   189       8
## 2        KD Mills     6       0   199       7
## 3     NL McCullum    15       0   281       5
## 4      TG Southee     3       0   183       5
## 5       CS Martin     5       0   116       5
## 6      DL Vettori    11       0    91       5
## 7    JEC Franklin     7       0    53       5
## 8         SE Bond     8       0    49       5
## 9       IG Butler    11       0    95       4
## 10      SB Styris     8       0    80       3
## ..            ...   ...     ...   ...     ...
# Best Sri Lankan bowlers in matches against West Indies
teamBowlingScorecardAllOppnAllMatches(sl_matches,"West Indies")
## Source: local data frame [16 x 5]
## 
##              bowler overs maidens  runs wickets
##              (fctr) (int)   (int) (dbl)   (dbl)
## 1        BAW Mendis    10       0    82      13
## 2        SL Malinga    12       0   217      12
## 3        AD Mathews     9       0    87       6
## 4   TAM Siriwardana     5       0    58       5
## 5   SMSM Senanayake     7       0    90       4
## 6    M Muralitharan     9       0    76       4
## 7   KMDN Kulasekara    11       0   158       3
## 8      PVD Chameera     4       0    66       2
## 9           I Udana     7       0    56       1
## 10 DSNFG Jayasuriya     2       0    38       1
## 11      BMAJ Mendis     1       0    32       1
## 12      A Dananjaya     1       0    16       1
## 13       S Prasanna     2       0    15       1
## 14     HMRKB Herath     5       0    43       0
## 15    ST Jayasuriya     3       0    34       0
## 16      NLTC Perera     2       0    13       0

18. Team Bowlers versus Batsmen (in T20 against all oppositions)

The functions below give the peformance of bowlers versus batsman. They give the best bowlers and the total runs conceded and against whom were the runs conceded

# Best T20 bowlers overall from India against all opposition (rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(ind_matches,theTeam="India",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1         R Ashwin   868
## 2        RA Jadeja   619
## 3        IK Pathan   598
## 4  Harbhajan Singh   591
## 5           Z Khan   424
## 6     Yuvraj Singh   415
## 7        YK Pathan   406
## 8          A Nehra   368
## 9         I Sharma   349
## 10         B Kumar   275
# Top T20 bowler of India and runs conceded against different opposition batsmen 
(rank=1)
## [1] 1
m <-teamBowlersVsBatsmenAllOppnAllMatchesMain(ind_matches,theTeam="India",rank=1)
m
## Source: local data frame [95 x 3]
## Groups: bowler [1]
## 
##      bowler     batsman runsConceded
##      (fctr)      (fctr)        (dbl)
## 1  R Ashwin    AD Hales           43
## 2  R Ashwin    AJ Finch           42
## 3  R Ashwin   SR Watson           41
## 4  R Ashwin   DA Warner           37
## 5  R Ashwin     MS Wade           37
## 6  R Ashwin BB McCullum           26
## 7  R Ashwin   JP Duminy           26
## 8  R Ashwin  GJ Maxwell           24
## 9  R Ashwin  EJG Morgan           24
## 10 R Ashwin   CA Ingram           23
## ..      ...         ...          ...
# Top T20 bowler of India and runs conceded against different opposition batsmen (rank=2)
m <-teamBowlersVsBatsmenAllOppnAllMatchesMain(ind_matches,theTeam="India",rank=2)
m
## Source: local data frame [66 x 3]
## Groups: bowler [1]
## 
##       bowler       batsman runsConceded
##       (fctr)        (fctr)        (dbl)
## 1  RA Jadeja     SR Watson           59
## 2  RA Jadeja      AJ Finch           34
## 3  RA Jadeja       MS Wade           32
## 4  RA Jadeja CK Kapugedera           24
## 5  RA Jadeja   LMP Simmons           23
## 6  RA Jadeja      AD Hales           22
## 7  RA Jadeja     DA Warner           20
## 8  RA Jadeja     JH Kallis           19
## 9  RA Jadeja    EJG Morgan           17
## 10 RA Jadeja  LD Chandimal           17
## ..       ...           ...          ...

18. Team Bowlers versus Batsmen (in T20 matchesagainst all oppositions continued)

# Top T20 bowlers versus batsmen of South Africa(rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(sa_matches,theTeam="South Africa",rank=0)
## Source: local data frame [10 x 2]
## 
##         bowler  runs
##         (fctr) (dbl)
## 1     M Morkel   967
## 2   WD Parnell   858
## 3     DW Steyn   833
## 4    JA Morkel   807
## 5      J Botha   802
## 6  LL Tsotsobe   523
## 7  RJ Peterson   443
## 8  Imran Tahir   410
## 9    JP Duminy   406
## 10   KJ Abbott   353
# Top T20 bowlers versus batsmen of Pakistan(rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(pak_matches,theTeam="Pakistan",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1    Shahid Afridi  2054
## 2      Saeed Ajmal  1475
## 3         Umar Gul  1330
## 4    Sohail Tanvir  1147
## 5  Mohammad Hafeez  1060
## 6    Mohammad Amir   546
## 7     Shoaib Malik   407
## 8    Shoaib Akhtar   402
## 9       Wahab Riaz   369
## 10    Abdul Razzaq   364
# Top T20 bowlers versus batsmen of Sri Lanka(rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(sl_matches,theTeam="Sri Lanka",rank=1)
## Source: local data frame [168 x 3]
## Groups: bowler [1]
## 
##        bowler       batsman runsConceded
##        (fctr)        (fctr)        (dbl)
## 1  SL Malinga Shahid Afridi           66
## 2  SL Malinga    MN Samuels           55
## 3  SL Malinga   BB McCullum           38
## 4  SL Malinga    MJ Guptill           37
## 5  SL Malinga     G Gambhir           35
## 6  SL Malinga   NL McCullum           35
## 7  SL Malinga      JDP Oram           31
## 8  SL Malinga  Shoaib Malik           31
## 9  SL Malinga    MEK Hussey           30
## 10 SL Malinga  ADS Fletcher           30
## ..        ...           ...          ...
m <-teamBowlersVsBatsmenAllOppnAllMatchesMain(ind_matches,theTeam="India",rank=2)
m
## Source: local data frame [66 x 3]
## Groups: bowler [1]
## 
##       bowler       batsman runsConceded
##       (fctr)        (fctr)        (dbl)
## 1  RA Jadeja     SR Watson           59
## 2  RA Jadeja      AJ Finch           34
## 3  RA Jadeja       MS Wade           32
## 4  RA Jadeja CK Kapugedera           24
## 5  RA Jadeja   LMP Simmons           23
## 6  RA Jadeja      AD Hales           22
## 7  RA Jadeja     DA Warner           20
## 8  RA Jadeja     JH Kallis           19
## 9  RA Jadeja    EJG Morgan           17
## 10 RA Jadeja  LD Chandimal           17
## ..       ...           ...          ...

19. Team bowlers versus batsmen report (in T20 matches against all oppositions)

#Top T20 bowlers of other countries against India
teamBowlersVsBatsmenAllOppnAllMatchesRept(matches=ind_matches,theTeam="India",rank=0)
## Source: local data frame [10 x 2]
## 
##           bowler  runs
##           (fctr) (dbl)
## 1      SR Watson   190
## 2  Shahid Afridi   180
## 3       Umar Gul   171
## 4      SCJ Broad   151
## 5    JW Dernbach   149
## 6     SL Malinga   144
## 7     TT Bresnan   135
## 8    JP Faulkner   127
## 9          B Lee   123
## 10     JA Morkel   121
# Best T20 performer against India is Shane Watosn in T20s
a <- teamBowlersVsBatsmenAllOppnAllMatchesRept(ind_matches,theTeam="India",rank=1)
a
## Source: local data frame [12 x 3]
## Groups: bowler [1]
## 
##       bowler         batsman runsConceded
##       (fctr)          (fctr)        (dbl)
## 1  SR Watson       RG Sharma           41
## 2  SR Watson         V Kohli           39
## 3  SR Watson        SK Raina           26
## 4  SR Watson    Yuvraj Singh           23
## 5  SR Watson        MS Dhoni           21
## 6  SR Watson       IK Pathan           14
## 7  SR Watson        S Dhawan           10
## 8  SR Watson Harbhajan Singh            7
## 9  SR Watson       RA Jadeja            4
## 10 SR Watson        R Ashwin            4
## 11 SR Watson       AM Rahane            1
## 12 SR Watson         B Kumar            0

20. Team bowlers versus batsmen report (in T20s against all oppositions continued)

#Top T20 Indian bowlers against Sri Lanka 
teamBowlersVsBatsmenAllOppnAllMatchesRept(matches=ind_matches,theTeam="Sri Lanka",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1          A Nehra   140
## 2        YK Pathan   100
## 3        RA Jadeja    80
## 4         R Ashwin    74
## 5         I Sharma    60
## 6         SK Raina    58
## 7        IK Pathan    56
## 8         AB Dinda    53
## 9  Harbhajan Singh    35
## 10       JJ Bumrah    35
#Top T20 Indian bowlers against England
teamBowlersVsBatsmenAllOppnAllMatchesRept(ind_matches,"England",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1         R Ashwin   160
## 2        RA Jadeja    86
## 3         AB Dinda    86
## 4          P Awana    71
## 5        PP Chawla    68
## 6  Harbhajan Singh    61
## 7     Yuvraj Singh    58
## 8  Joginder Sharma    57
## 9    R Vinay Kumar    53
## 10       IK Pathan    52

21. Team T20 bowlers versus batsmen report (all oppositions coninued-1)

#Top  T20 opposition bowlers against New Zealand
teamBowlersVsBatsmenAllOppnAllMatchesRept(nz_matches,theTeam="New Zealand",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1    Shahid Afridi   333
## 2         M Morkel   283
## 3        SCJ Broad   279
## 4       SL Malinga   260
## 5         Umar Gul   240
## 6  KMDN Kulasekara   199
## 7    Mohammad Amir   192
## 8       BAW Mendis   190
## 9      Saeed Ajmal   170
## 10        P Utseya   159
# Top T20 opposition bowlers against Australia
teamBowlersVsBatsmenAllOppnAllMatchesRept(aus_matches,"Australia",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1      Saeed Ajmal   265
## 2       WD Parnell   254
## 3    Shahid Afridi   249
## 4        SCJ Broad   239
## 5         R Ashwin   222
## 6         Umar Gul   222
## 7        RA Jadeja   218
## 8          J Botha   210
## 9  Mohammad Hafeez   207
## 10     JW Dernbach   188
# Top T20 bowlers against Sri Lanka
teamBowlersVsBatsmenAllOppnAllMatchesRept(sl_matches,"Sri Lanka",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1    Shahid Afridi   291
## 2    Sohail Tanvir   273
## 3      Saeed Ajmal   223
## 4         KD Mills   204
## 5         Umar Gul   179
## 6         DJ Bravo   173
## 7  Mohammad Hafeez   170
## 8       DL Vettori   160
## 9         JDP Oram   159
## 10      KA Pollard   157

22. Team bowlers versus batsmen report (in T20s against all oppositions) plot

This function can only be used for rank > 0 (rank=1,2,3..)

# Top T20 bowler against India (Shane Watson of Australia)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(ind_matches,theTeam="India",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"India","India")

# Top T20 Indian bowler versus England (R Ashwin)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(ind_matches,theTeam="England",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"India","England")

#Top T20 Indian bowler against West Indies (Yusuf Pathan)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(ind_matches,theTeam="West Indies",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"India","West Indies")

23. Team bowlers versus batsmen plot (in Twenty20 matches against all oppositions)

#Top T20 bowler against South Africa (NL McCullum of New Zealand)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(sa_matches,theTeam="South Africa",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"South Africa","South Africa")
## [1] "aa"

# Top  T20 bowler versus Pakistan (SL Malinga)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(pak_matches,theTeam="Pakistan",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"Pakistan","Pakistan")

24. Team Bowler Wicket Kind in Twenty20 matches against all oppositions

# Top opposition T20  bowlers against India and the kind of wickets
teamBowlingWicketKindAllOppnAllMatches(ind_matches,t1="India",t2="All")

# Get the data frame. Do not plot
m <-teamBowlingWicketKindAllOppnAllMatches(ind_matches,t1="India",t2="All",plot=FALSE)
m
## Source: local data frame [21 x 3]
## Groups: bowler [?]
## 
##         bowler wicketKind     m
##         (fctr)      (chr) (int)
## 1   MG Johnson     caught     3
## 2   MG Johnson    run out     2
## 3    SR Watson     caught     8
## 4    SR Watson    run out     3
## 5   TT Bresnan     caught     6
## 6  JW Dernbach     bowled     1
## 7  JW Dernbach     caught     6
## 8  JW Dernbach    run out     3
## 9      ST Finn     bowled     2
## 10     ST Finn     caught     4
## ..         ...        ...   ...
# Best Indian T20 bowlers against South Africa
teamBowlingWicketKindAllOppnAllMatches(ind_matches,t1="India",t2="South Africa")

# Best Indian bowlers against Pakistan
teamBowlingWicketKindAllOppnAllMatches(ind_matches,t1="India",t2="Pakistan")

25. Team Bowler Wicket Kind in Twenty20 matches against all oppositions (continued)

# Best T20 opposition bowlers against  England
teamBowlingWicketKindAllOppnAllMatches(eng_matches,t1="England",t2="All")

# Best t20  opposition bowlers  Australia
teamBowlingWicketKindAllOppnAllMatches(aus_matches,t1="Australia",t2="All")

# Best T20 bowlers against  Sri Lanka
teamBowlingWicketKindAllOppnAllMatches(sl_matches,t1="Sri Lanka",t2="All")

26. Team Bowler Wicket Runs in Twenty20 matches against all oppositions

# Opposition T20 bowlers against India and runs conceded
teamBowlingWicketRunsAllOppnAllMatches(ind_matches,t1="India",t2="All",plot=TRUE)

# Opposition T20 bowlers against India and runs conceded returned as dataframe
m <-teamBowlingWicketRunsAllOppnAllMatches(ind_matches,t1="India",t2="All",plot=FALSE)
m
## Source: local data frame [10 x 3]
## 
##           bowler runsConceded wickets
##           (fctr)        (dbl)   (dbl)
## 1      SR Watson          201      11
## 2       Umar Gul          178      11
## 3    JW Dernbach          157      10
## 4        ST Finn           83       7
## 5       CB Mpofu          119       7
## 6     TT Bresnan          140       6
## 7     DL Vettori           96       6
## 8     MG Johnson           54       5
## 9  Mohammad Asif           43       5
## 10 Shahid Afridi          184       5
# Top T20 Indian bowlers and runs conceded
teamBowlingWicketRunsAllOppnAllMatches(ind_matches,t1="India",t2="Australia",plot=TRUE)

27. Team Bowler Wicket Runs in Twenty20 matches against all oppositions(continued)

#Top opposition T20 bowlers against Pakistan
teamBowlingWicketRunsAllOppnAllMatches(pak_matches,t1="Pakistan",t2="All",plot=TRUE)

#Top opposition T20 bowlers against West Indies
teamBowlingWicketRunsAllOppnAllMatches(wi_matches,t1="West Indies",t2="All",plot=TRUE)

#Top opposition t20 bowlers against Sri Lanka
teamBowlingWicketRunsAllOppnAllMatches(sl_matches,t1="Sri Lanka",t2="All",plot=TRUE)

#Top opposition T20 bowlers against New Zealand
teamBowlingWicketRunsAllOppnAllMatches(nz_matches,t1="New Zealand",t2="All",plot=TRUE)

Conclusion

This post included all functions for a team in all Twenty20 matches against all oppositions. As before the data frames for the T20 matches are already available. You can load the data and begin to use them. If more insights from the dataframe are possible do go ahead. But please do attribute the source to Cricheet (http://cricsheet.org), my package yorkr and my blog. Do give the functions a spin for yourself.

The 4th part of the yorkr package’s handling of Twenty20 will follow soon.

Watch this space!

You may also like

  1. Introducing cricket package yorkr-Part1:Beaten by sheer pace!
  2. Introducing cricket package yorkr:Part 4-In the block hole!
  3. Literacy in India: A deepR dive
  4. Simulating an Edge shape in Android
  5. Re-working the Lucy Richardson algorithm in OpenCV
  6. Introducing cricketr! : An R package to analyze performances of cricketers
  7. Design principles of scalable distributed systems
  8. OpenCV: Fun with filters and convolution
  9. Getting started with memcached-libmemcached

To leave a comment for the author, please follow the link and comment on their blog: R – Giga thoughts ….

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.