yorkr crashes the IPL party! – Part 3!

[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

“I’m sorry, if you were right, I’d agree with you.”

                 Robin Williams

Get your facts first. Then you can distort them as you please.

                 Mark Twain
                 

Do not take life too seriously. You will never get out of it alive.

                 Elbert Hubbard

This is the 3rd post in the “yorkr crashes the IPL party!” series. The 2 earlier ones were

  1. yorkr crashes the IPL party ! – Part 1
  2. yorkr crashes the IPL party ! – Part 2

This post deals with Class 3 functions, namely the performances of an IPL team in all matches against all other IPL teams matches for e.g Chennai Super Kings against all other IPL teams or Delhi Daredevils against all other teams.

This post has also been published at RPubs IPLT20-Part3 and can also be downloaded as a PDF document from IPLT20-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: 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 IPL matches against all other IPL teams using the function below. The dir parameter should point to the folder in which the RData files where the individual IPL 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/IPL/IPL-T20-team-allMatches-allOppostions")
# Get all matches against all oppositions for India and save as RData
matches <-getAllMatchesAllOpposition("Royal Challengers Bangalore",dir=".",save=TRUE)
dim(matches)
## [1] 28199    25

“`

3. Save data for all matches against all oppositions

This can be done locally using the function below. This function gets all the IPL T20 matches of the IPL team against all other IPL 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. However you will need to use this function for future matches!

# To be available in yorkr_0.0.5. You can install from Github though.
#saveAllMatchesAllOppositionIPLT20()

4. Load data directly for all matches between 2 teams

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

Note: The dataframe for the different for all the matches of a IPL team against all other IPL teams 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 any random IPL team for the funtions for illustration

setwd("C:/software/cricket-package/york-test/yorkrData/IPL/IPL-T20-team-allMatches-allOppostions")
load("allMatchesAllOpposition-Chennai Super Kings.RData")
csk_Allmatches <- matches
load("allMatchesAllOpposition-Deccan Chargers.RData")
dc_Allmatches <- matches
load("allMatchesAllOpposition-Delhi Daredevils.RData")
dd_Allmatches <- matches
load("allMatchesAllOpposition-Kings XI Punjab.RData")
kxip_Allmatches <- matches
load("allMatchesAllOpposition-Kochi Tuskers Kerala.RData")
ktk_Allmatches <- matches
load("allMatchesAllOpposition-Kolkata Knight Riders.RData")
kkr_Allmatches <- matches
load("allMatchesAllOpposition-Mumbai Indians.RData")
mi_Allmatches <- matches
load("allMatchesAllOpposition-Pune Warriors.RData")
pw_Allmatches <- matches
load("allMatchesAllOpposition-Rajasthan Royals.RData")
rr_Allmatches <- matches
load("allMatchesAllOpposition-Royal Challengers Bangalore.RData")
rcb_Allmatches <- matches
load("allMatchesAllOpposition-Sunrisers Hyderabad.RData")
sh_Allmatches <- matches

5. Team IPL T20 Batting Scorecard (all matches with all opposing IPL teams)

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

#Top IPL Twenty20 batsmen for Chennai Super Kings
m <-teamBattingScorecardAllOppnAllMatches(csk_Allmatches,theTeam="Chennai Super Kings")
## Total= 19312
m
## Source: local data frame [46 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1      SK Raina        2513   312   144  3567
## 2      MS Dhoni        2036   206   121  2887
## 3    MEK Hussey        1361   178    43  1721
## 4       M Vijay        1220   140    64  1574
## 5   S Badrinath        1171   152    28  1427
## 6  F du Plessis         837    92    29  1081
## 7     ML Hayden         725   118    43  1077
## 8      DR Smith         673    98    42   886
## 9     JA Morkel         549    50    47   812
## 10  BB McCullum         562    78    42   809
## ..          ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Deccan Chargers
m <-teamBattingScorecardAllOppnAllMatches(dc_Allmatches,theTeam="Deccan Chargers")
## Total= 10885
m
## Source: local data frame [58 x 5]
## 
##            batsman ballsPlayed fours sixes  runs
##             (fctr)       (int) (int) (int) (dbl)
## 1     AC Gilchrist         802   136    64  1220
## 2        RG Sharma         866    96    51  1170
## 3         S Dhawan         737   106    25   969
## 4        A Symonds         600    65    38   839
## 5         HH Gibbs         695    75    29   805
## 6         CL White         425    47    22   583
## 7    KC Sangakkara         458    65     9   558
## 8         TL Suman         437    41    20   544
## 9        JP Duminy         360    22    19   449
## 10 Y Venugopal Rao         357    32    19   446
## ..             ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Delhi Daredevils
m <-teamBattingScorecardAllOppnAllMatches(dd_Allmatches,theTeam="Delhi Daredevils")
## Total= 16324
m
## Source: local data frame [76 x 5]
## 
##             batsman ballsPlayed fours sixes  runs
##              (fctr)       (int) (int) (int) (dbl)
## 1          V Sehwag        1290   257    84  2127
## 2         DA Warner        1050   146    58  1435
## 3         G Gambhir         828   126    12  1058
## 4        KD Karthik         762    82    27   979
## 5         JP Duminy         585    44    40   796
## 6  DPMD Jayawardene         600    79     9   666
## 7    AB de Villiers         541    50    13   650
## 8      KP Pietersen         431    56    27   599
## 9        TM Dilshan         452    62    16   562
## 10        KM Jadhav         394    42    19   537
## ..              ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Kolkata Knight Riders
m <-teamBattingScorecardAllOppnAllMatches(kkr_Allmatches,theTeam="Kolkata Knight Riders")
## Total= 16001
m
## Source: local data frame [69 x 5]
## 
##        batsman ballsPlayed fours sixes  runs
##         (fctr)       (int) (int) (int) (dbl)
## 1    G Gambhir        1583   235    33  2024
## 2    YK Pathan         937   100    64  1317
## 3    JH Kallis        1193   128    23  1294
## 4   SC Ganguly         909   105    36  1031
## 5   RV Uthappa         739   118    25  1024
## 6    MK Tiwary         878    86    23  1002
## 7  BB McCullum         709    92    32   882
## 8    MK Pandey         518    58    17   626
## 9     MS Bisla         470    60    16   542
## 10   DJ Hussey         389    31    28   511
## ..         ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Kochi Tuskers Kerala
m <-teamBattingScorecardAllOppnAllMatches(ktk_Allmatches,theTeam="Kochi Tuskers Kerala")
## Total= 1758
m
## Source: local data frame [19 x 5]
## 
##             batsman ballsPlayed fours sixes  runs
##              (fctr)       (int) (int) (int) (dbl)
## 1       BB McCullum         265    35    16   357
## 2  DPMD Jayawardene         249    35     5   299
## 3          BJ Hodge         230    26     9   285
## 4         RA Jadeja         225    20    14   283
## 5          PA Patel         181    25     2   202
## 6         M Klinger          74     9    NA    73
## 7     R Vinay Kumar          47     4     1    50
## 8          RV Gomez          47     4     1    46
## 9        VVS Laxman          38     3     2    44
## 10          OA Shah          14     1     2    26
## 11      NLTC Perera          27     4    NA    23
## 12 Y Gnaneswara Rao          17     3    NA    19
## 13        KM Jadhav          23     1    NA    18
## 14          B Akhil           9    NA     1    13
## 15         RR Powar          13    NA    NA    11
## 16   M Muralitharan           6    NA    NA     5
## 17         RP Singh           3    NA    NA     2
## 18      S Sreesanth           8    NA    NA     1
## 19   P Parameswaran           1    NA    NA     1
#Top IPL Twenty20 batsmen for Kings XI Punjab
m <-teamBattingScorecardAllOppnAllMatches(kxip_Allmatches,theTeam="Kings XI Punjab")
## Total= 17333
m
## Source: local data frame [74 x 5]
## 
##             batsman ballsPlayed fours sixes  runs
##              (fctr)       (int) (int) (int) (dbl)
## 1          SE Marsh        1444   211    65  1973
## 2         DA Miller         865    89    70  1319
## 3     KC Sangakkara         755   117    18  1000
## 4      Yuvraj Singh         643    67    46   859
## 5      AC Gilchrist         636   103    28   849
## 6  DPMD Jayawardene         546    81    24   792
## 7     Mandeep Singh         616    96     8   763
## 8        GJ Maxwell         388    61    44   697
## 9         DJ Hussey         567    51    26   695
## 10          WP Saha         437    49    28   611
## ..              ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Mumbai Indians
m <-teamBattingScorecardAllOppnAllMatches(mi_Allmatches,theTeam="Mumbai Indians")
## Total= NA
m
## Source: local data frame [73 x 5]
## 
##          batsman ballsPlayed fours sixes  runs
##           (fctr)       (int) (int) (int) (dbl)
## 1   SR Tendulkar        1806   277    29  2221
## 2      RG Sharma        1657   176    96  2201
## 3      AT Rayudu        1507   169    63  1963
## 4     KA Pollard        1117   116   106  1707
## 5    LMP Simmons         720    99    35   934
## 6  ST Jayasuriya         504    84    37   748
## 7     KD Karthik         591    82    16   727
## 8       DR Smith         449    62    26   600
## 9      JP Duminy         437    39    16   523
## 10     SS Tiwary         332    32    19   458
## ..           ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Pune Warriors
m <-teamBattingScorecardAllOppnAllMatches(pw_Allmatches,theTeam="Pune Warriors")
## Total= 5871
m
## Source: local data frame [43 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1    RV Uthappa         880   106    30  1078
## 2  Yuvraj Singh         427    38    30   551
## 3      JD Ryder         396    60    19   548
## 4     SPD Smith         388    39    18   521
## 5     MK Pandey         421    44    14   459
## 6      AJ Finch         293    52    13   408
## 7    SC Ganguly         321    33     6   318
## 8    AD Mathews         246    10    14   299
## 9      M Manhas         234    19     8   247
## 10     MR Marsh         153     8    13   190
## ..          ...         ...   ...   ...   ...
#Top Twenty20 batsmen for Rajasthan Royals
m <-teamBattingScorecardAllOppnAllMatches(rr_Allmatches,theTeam="Rajasthan Royals")
## Total= 16359
m
## Source: local data frame [80 x 5]
## 
##      batsman ballsPlayed fours sixes  runs
##       (fctr)       (int) (int) (int) (dbl)
## 1  SR Watson        1609   237   107  2342
## 2  AM Rahane        1637   218    38  2031
## 3   R Dravid        1098   171    10  1247
## 4  YK Pathan         601    89    59   990
## 5  SV Samson         596    59    30   740
## 6   GC Smith         601    88     9   697
## 7   BJ Hodge         423    41    24   592
## 8  STR Binny         438    43    21   572
## 9    KK Nair         369    56    14   511
## 10   NV Ojha         385    49    25   501
## ..       ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Royal Challengers Bangalore
m <-teamBattingScorecardAllOppnAllMatches(rcb_Allmatches,theTeam="Royal Challengers Bangalore")
## Total= 17288
m
## Source: local data frame [85 x 5]
## 
##           batsman ballsPlayed fours sixes  runs
##            (fctr)       (int) (int) (int) (dbl)
## 1         V Kohli        2470   274   111  3125
## 2        CH Gayle        1704   217   204  2736
## 3  AB de Villiers        1170   167    90  1899
## 4       JH Kallis         952   123    20  1093
## 5        R Dravid         706    96    17   889
## 6      TM Dilshan         510    78     8   587
## 7      RV Uthappa         380    39    30   549
## 8       SS Tiwary         456    26    17   487
## 9     LRPL Taylor         318    33    28   464
## 10     MA Agarwal         332    41    22   433
## ..            ...         ...   ...   ...   ...
#Top IPL Twenty20 batsmen for Sunrisers Hyderabad
m <-teamBattingScorecardAllOppnAllMatches(sh_Allmatches,theTeam="Sunrisers Hyderabad")
## Total= 6117
m
## Source: local data frame [32 x 5]
## 
##         batsman ballsPlayed fours sixes  runs
##          (fctr)       (int) (int) (int) (dbl)
## 1     DA Warner         715   104    45  1090
## 2      S Dhawan         835   131    18  1040
## 3       NV Ojha         277    26    21   369
## 4      AJ Finch         251    31     9   309
## 5      KL Rahul         284    20     8   308
## 6  MC Henriques         220    20    13   296
## 7      PA Patel         244    37     4   292
## 8     GH Vihari         281    23     1   261
## 9     DJG Sammy         198    14    17   259
## 10    KV Sharma         191    10    11   227
## ..          ...         ...   ...   ...   ...

6. Team Batting Scorecard in IPL Twenty20 matches against all opposing IPL teams

The following functions show the best batsmen from the opposition ‘theTeam’ in the ‘matches’. For e.g. when the matches=csk_Allmatches and theTeam=“Royal Challengers Bangalore” then the returned dataframe shows the best Royal Challengers Bangalore batsmen against CSK

#Top IPL T20  Royal Challengers Bangalore batsmen against Chennai Super Kings
m <-teamBattingScorecardAllOppnAllMatches(matches=csk_Allmatches,theTeam="Royal Challengers Bangalore")
## Total= 2485
m
## Source: local data frame [54 x 5]
## 
##           batsman ballsPlayed fours sixes  runs
##            (fctr)       (int) (int) (int) (dbl)
## 1         V Kohli         542    49    30   694
## 2        CH Gayle         204    12    23   270
## 3  AB de Villiers         147    26     9   241
## 4        R Dravid         111    18    NA   133
## 5      MA Agarwal          96    15     4   120
## 6      RV Uthappa          71     7     8   115
## 7       JH Kallis          95    19    NA   109
## 8       SS Tiwary          84     4     3    86
## 9       MK Pandey          67    10    NA    73
## 10    LRPL Taylor          62     2     3    64
## ..            ...         ...   ...   ...   ...
#Top IPL T20 Mumbai Indians batsmen against Chennai Super Kings
m <-teamBattingScorecardAllOppnAllMatches(matches=csk_Allmatches,theTeam="Mumbai Indians")
## Total= 3223
m
## Source: local data frame [43 x 5]
## 
##            batsman ballsPlayed fours sixes  runs
##             (fctr)       (int) (int) (int) (dbl)
## 1        RG Sharma         343    37    14   444
## 2       KA Pollard         209    25    26   351
## 3     SR Tendulkar         259    38     5   320
## 4        AT Rayudu         243    17    14   299
## 5      LMP Simmons         219    23    16   281
## 6    ST Jayasuriya          91    21    13   190
## 7  Harbhajan Singh         115    13    12   170
## 8         DR Smith          90    16    10   159
## 9         AM Nayar          59    10     6   113
## 10      KD Karthik         100    13     2   109
## ..             ...         ...   ...   ...   ...
#Top IPL T20 Rajasthan Royals batsmen against Pune Warriors
m <-teamBattingScorecardAllOppnAllMatches(pw_Allmatches,theTeam="Rajasthan Royals")
## Total= 743
m
## Source: local data frame [13 x 5]
## 
##        batsman ballsPlayed fours sixes  runs
##         (fctr)       (int) (int) (int) (dbl)
## 1    AM Rahane         134    18     2   173
## 2    SR Watson         100    17     9   165
## 3     R Dravid         140    25     1   165
## 4   AL Menaria          42     1     3    47
## 5  LRPL Taylor          33     4     2    47
## 6     BJ Hodge          37     3    NA    40
## 7    STR Binny          22     2     2    39
## 8  JP Faulkner          16     1     1    22
## 9      J Botha          20     2    NA    19
## 10   DH Yagnik           8     2    NA    12
## 11   SV Samson           6     2    NA    10
## 12     OA Shah           7    NA    NA     4
## 13 MDKJ Perera           1    NA    NA     0
#Top IPL T20 Sunrisers Hyderabad batsmen against West Indies
m <-teamBattingScorecardAllOppnAllMatches(kkr_Allmatches,theTeam="Sunrisers Hyderabad")
## Total= 814
m
## Source: local data frame [27 x 5]
## 
##            batsman ballsPlayed fours sixes  runs
##             (fctr)       (int) (int) (int) (dbl)
## 1         S Dhawan         138    19     3   159
## 2        DA Warner          76    14     6   133
## 3         PA Patel          65     9     1    74
## 4          NV Ojha          56     7     5    66
## 5        DJG Sammy          44     1     5    53
## 6     MC Henriques          38     3     2    48
## 7        KV Sharma          35     1     3    46
## 8      NLTC Perera          34     2     1    40
## 9         CL White          33     3     1    36
## 10 Y Venugopal Rao          24     4    NA    27
## ..             ...         ...   ...   ...   ...

7. Team Batting Partnerships of an IL T20 matches against all opposing teams

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

# The function gives the names of highest IPL T20 partnership for Chennai Super Kings. The default report parameter is "summary"
m <- teamBatsmenPartnershipAllOppnAllMatches(csk_Allmatches,theTeam='Chennai Super Kings')
m
## Source: local data frame [46 x 2]
## 
##         batsman totalRuns
##          (fctr)     (dbl)
## 1      SK Raina      3567
## 2      MS Dhoni      2887
## 3    MEK Hussey      1721
## 4       M Vijay      1574
## 5   S Badrinath      1427
## 6  F du Plessis      1081
## 7     ML Hayden      1077
## 8      DR Smith       886
## 9     JA Morkel       812
## 10  BB McCullum       809
## ..          ...       ...
# When the report parameter is 'detailed' then the detailed break up of the T20 partnership is returned as a data frame
m <- teamBatsmenPartnershipAllOppnAllMatches(csk_Allmatches,theTeam='Chennai Super Kings',report="detailed")
head(m,30)
##     batsman   nonStriker partnershipRuns totalRuns
## 1  SK Raina   SP Fleming              20      3567
## 2  SK Raina   S Anirudha              33      3567
## 3  SK Raina  S Badrinath             413      3567
## 4  SK Raina     MS Dhoni             546      3567
## 5  SK Raina    JA Morkel             142      3567
## 6  SK Raina      MS Gony              10      3567
## 7  SK Raina    ML Hayden             219      3567
## 8  SK Raina     JDP Oram               6      3567
## 9  SK Raina     DR Smith             239      3567
## 10 SK Raina      M Vijay             325      3567
## 11 SK Raina      JM Kemp              10      3567
## 12 SK Raina     R Ashwin               0      3567
## 13 SK Raina   MEK Hussey             617      3567
## 14 SK Raina F du Plessis             336      3567
## 15 SK Raina    RA Jadeja              50      3567
## 16 SK Raina     DJ Bravo              87      3567
## 17 SK Raina     PA Patel             166      3567
## 18 SK Raina     S Vidyut               1      3567
## 19 SK Raina   A Flintoff              30      3567
## 20 SK Raina      WP Saha              16      3567
## 21 SK Raina  BB McCullum             186      3567
## 22 SK Raina    GJ Bailey              10      3567
## 23 SK Raina    DJ Hussey              95      3567
## 24 SK Raina      M Ntini               2      3567
## 25 SK Raina  C Ganapathy               8      3567
## 26 MS Dhoni   SP Fleming              11      2887
## 27 MS Dhoni   S Anirudha              29      2887
## 28 MS Dhoni     SK Raina             488      2887
## 29 MS Dhoni  S Badrinath             341      2887
## 30 MS Dhoni    JA Morkel             209      2887
#Top IPL T20 Rajasthan Royal partnerships 
teamBatsmenPartnershipAllOppnAllMatches(rr_Allmatches,theTeam='Rajasthan Royals',report="summary")
## Source: local data frame [80 x 2]
## 
##      batsman totalRuns
##       (fctr)     (dbl)
## 1  SR Watson      2342
## 2  AM Rahane      2031
## 3   R Dravid      1247
## 4  YK Pathan       990
## 5  SV Samson       740
## 6   GC Smith       697
## 7   BJ Hodge       592
## 8  STR Binny       572
## 9    KK Nair       511
## 10   NV Ojha       501
## ..       ...       ...
#Top IPL T20 Mumbai Indians batting partnerships 
m <- teamBatsmenPartnershipAllOppnAllMatches(mi_Allmatches,theTeam='Mumbai Indians',report="detailed")
m[1:30,]
##         batsman        nonStriker partnershipRuns totalRuns
## 1  SR Tendulkar     ST Jayasuriya             254      2221
## 2  SR Tendulkar        RV Uthappa              10      2221
## 3  SR Tendulkar          DJ Bravo              66      2221
## 4  SR Tendulkar          AM Nayar              41      2221
## 5  SR Tendulkar   Harbhajan Singh              50      2221
## 6  SR Tendulkar          S Dhawan             183      2221
## 7  SR Tendulkar         JP Duminy             107      2221
## 8  SR Tendulkar            Z Khan               2      2221
## 9  SR Tendulkar           PR Shah              19      2221
## 10 SR Tendulkar         SS Tiwary              81      2221
## 11 SR Tendulkar         AT Rayudu             261      2221
## 12 SR Tendulkar        KA Pollard              65      2221
## 13 SR Tendulkar         R Sathish              62      2221
## 14 SR Tendulkar         R McLaren              33      2221
## 15 SR Tendulkar           RE Levi              14      2221
## 16 SR Tendulkar         RG Sharma             226      2221
## 17 SR Tendulkar      JEC Franklin              82      2221
## 18 SR Tendulkar          DR Smith             187      2221
## 19 SR Tendulkar        KD Karthik             104      2221
## 20 SR Tendulkar        RT Ponting              63      2221
## 21 SR Tendulkar           AP Tare              36      2221
## 22 SR Tendulkar       DJ Thornely              21      2221
## 23 SR Tendulkar          HH Gibbs              13      2221
## 24 SR Tendulkar          TL Suman              19      2221
## 25 SR Tendulkar         A Symonds              13      2221
## 26 SR Tendulkar         DJ Jacobs              68      2221
## 27 SR Tendulkar         AM Rahane              36      2221
## 28 SR Tendulkar Mohammad Ashraful               1      2221
## 29 SR Tendulkar       RJ Peterson               9      2221
## 30 SR Tendulkar       AC Blizzard              77      2221
#Top IPL T20 Royal Challengers Bangalore batting partnerships 
m <-teamBatsmenPartnershipAllOppnAllMatches(rcb_Allmatches,theTeam='Royal Challengers Bangalore',report="detailed")
m[1:30,]
##    batsman      nonStriker partnershipRuns totalRuns
## 1  V Kohli      SP Goswami               7      3125
## 2  V Kohli       JH Kallis             181      3125
## 3  V Kohli        R Dravid              72      3125
## 4  V Kohli   Misbah-ul-Haq              13      3125
## 5  V Kohli      MV Boucher              39      3125
## 6  V Kohli         B Akhil               0      3125
## 7  V Kohli         P Kumar              17      3125
## 8  V Kohli        PA Patel              33      3125
## 9  V Kohli       JA Morkel               2      3125
## 10 V Kohli       MK Pandey              19      3125
## 11 V Kohli      RV Uthappa              32      3125
## 12 V Kohli    KP Pietersen              71      3125
## 13 V Kohli        CL White              25      3125
## 14 V Kohli      TM Dilshan              89      3125
## 15 V Kohli      MA Agarwal              74      3125
## 16 V Kohli  AB de Villiers             582      3125
## 17 V Kohli       SS Tiwary             154      3125
## 18 V Kohli       CA Pujara              56      3125
## 19 V Kohli      DL Vettori              12      3125
## 20 V Kohli        CH Gayle             855      3125
## 21 V Kohli   LA Pomersbach              39      3125
## 22 V Kohli J Syed Mohammad               1      3125
## 23 V Kohli      RR Bhatkal               0      3125
## 24 V Kohli   R Vinay Kumar              21      3125
## 25 V Kohli KB Arun Karthik               2      3125
## 26 V Kohli    Yuvraj Singh             126      3125
## 27 V Kohli          S Rana              23      3125
## 28 V Kohli    NJ Maddinson               6      3125
## 29 V Kohli   Mandeep Singh              23      3125
## 30 V Kohli      KD Karthik              92      3125

8. Batting Partnerships of opposing teams in IPL T20 matches with IPL team

When we use the dataframe rcb_Allmatches (matches of Royal Challengers Bangalore against all opposing teams) and choose another IPL team in the theTeam for e.g Rajasthan Royals then we will get the names of those top Rajasthan Royals batsmen against RCB.

# Top T20 Rajasthan Royals batting partnerships against Royal Challengers Bangalore (report="summary")
m <- teamBatsmenPartnershipAllOppnAllMatches(rcb_Allmatches,theTeam='Rajasthan Royals')
m
## Source: local data frame [50 x 2]
## 
##      batsman totalRuns
##       (fctr)     (dbl)
## 1  SR Watson       271
## 2  AM Rahane       256
## 3   R Dravid       177
## 4   GC Smith       146
## 5    KK Nair        92
## 6  YK Pathan        91
## 7  SPD Smith        91
## 8  SV Samson        87
## 9  STR Binny        80
## 10   NV Ojha        75
## ..       ...       ...
# Top T20 Kolkata Knight Riders  batting partnerships against Sunrisers Hyderabad (report="detailed")
m <- teamBatsmenPartnershipAllOppnAllMatches(sh_Allmatches,theTeam='Kolkata Knight Riders', report="detailed")
m[1:30,]
##             batsman       nonStriker partnershipRuns totalRuns
## 1         YK Pathan          J Botha              14       199
## 2         YK Pathan        PP Chawla              13       199
## 3         YK Pathan        JH Kallis              26       199
## 4         YK Pathan       RV Uthappa               3       199
## 5         YK Pathan        MK Pandey              28       199
## 6         YK Pathan RN ten Doeschate              22       199
## 7         YK Pathan  Shakib Al Hasan              36       199
## 8         YK Pathan         SA Yadav              32       199
## 9         YK Pathan          P Dogra              10       199
## 10        YK Pathan        SP Narine               9       199
## 11        YK Pathan    Iqbal Abdulla               6       199
## 12       RV Uthappa        G Gambhir              65       145
## 13       RV Uthappa        YK Pathan              19       145
## 14       RV Uthappa        MK Pandey              61       145
## 15        G Gambhir         MS Bisla              33       132
## 16        G Gambhir        JH Kallis              30       132
## 17        G Gambhir       RV Uthappa              69       132
## 18        MK Pandey        YK Pathan              31       103
## 19        MK Pandey       RV Uthappa              37       103
## 20        MK Pandey RN ten Doeschate              14       103
## 21        MK Pandey         SA Yadav               5       103
## 22        MK Pandey       AD Russell              16       103
## 23        JH Kallis       EJG Morgan              24        65
## 24        JH Kallis        G Gambhir              27        65
## 25        JH Kallis        YK Pathan              14        65
## 26       EJG Morgan        JH Kallis              56        56
## 27         MS Bisla        G Gambhir              43        43
## 28 RN ten Doeschate        YK Pathan              29        34
## 29 RN ten Doeschate        MK Pandey               5        34
## 30         SA Yadav        YK Pathan              11        20
#Top IPL T20 Chennai Super Kings batting partnerships  against Mumbai Indians
m <- teamBatsmenPartnershipAllOppnAllMatches(mi_Allmatches,theTeam='Chennai Super Kings',report="detailed")
head(m,30)
##     batsman      nonStriker partnershipRuns totalRuns
## 1  SK Raina       ML Hayden             104       537
## 2  SK Raina        PA Patel               5       537
## 3  SK Raina        MS Dhoni              23       537
## 4  SK Raina        DJ Bravo              59       537
## 5  SK Raina     S Badrinath              78       537
## 6  SK Raina         M Vijay              22       537
## 7  SK Raina      MEK Hussey              97       537
## 8  SK Raina    F du Plessis              43       537
## 9  SK Raina        DR Smith              51       537
## 10 SK Raina     BB McCullum               8       537
## 11 SK Raina       DJ Hussey              46       537
## 12 SK Raina      SP Fleming               1       537
## 13 MS Dhoni       ML Hayden              83       466
## 14 MS Dhoni        SK Raina               8       466
## 15 MS Dhoni        JDP Oram              10       466
## 16 MS Dhoni        DJ Bravo              63       466
## 17 MS Dhoni     S Badrinath              55       466
## 18 MS Dhoni Joginder Sharma              19       466
## 19 MS Dhoni         M Vijay               1       466
## 20 MS Dhoni      MEK Hussey               8       466
## 21 MS Dhoni    F du Plessis              24       466
## 22 MS Dhoni       JA Morkel              13       466
## 23 MS Dhoni       RA Jadeja              37       466
## 24 MS Dhoni        R Ashwin              52       466
## 25 MS Dhoni      B Laughlin              16       466
## 26 MS Dhoni      AS Rajpoot               9       466
## 27 MS Dhoni       CH Morris               1       466
## 28 MS Dhoni       MM Sharma              23       466
## 29 MS Dhoni     BB McCullum              14       466
## 30 MS Dhoni          P Negi              30       466
#Top IPL T20 Kochi Tusker Kerala batting partnerships  against Kings XI Punjab
m <- teamBatsmenPartnershipAllOppnAllMatches(kxip_Allmatches,theTeam='Kochi Tuskers Kerala',report="detailed")
head(m,30)
##             batsman       nonStriker partnershipRuns totalRuns
## 1  DPMD Jayawardene        RA Jadeja              12        76
## 2  DPMD Jayawardene      BB McCullum              42        76
## 3  DPMD Jayawardene         BJ Hodge               3        76
## 4  DPMD Jayawardene          OA Shah               9        76
## 5  DPMD Jayawardene         RV Gomez              10        76
## 6       BB McCullum DPMD Jayawardene              32        32
## 7           OA Shah DPMD Jayawardene              23        23
## 8         RA Jadeja DPMD Jayawardene              17        17
## 9          BJ Hodge DPMD Jayawardene               4         4
## 10         RV Gomez DPMD Jayawardene               2         2
## 11    R Vinay Kumar DPMD Jayawardene               1         1
## 12         PA Patel DPMD Jayawardene               0         0

9. Team Batting Partnership plots in Twenty20 matches against all opposing teams

Graphical plot of batting partnerships for the IPL teams

# Plot of IPL T20 batting partnerships of Chennai Super Kings (Suresh Raina  and MS Dhoni have the best IPL T20 partnerships for CSK)
teamBatsmenPartnershipAllOppnAllMatchesPlot(csk_Allmatches,"Chennai Super Kings",main="Chennai Super Kings")

batsmenPartnership1-1

# Plot of T20 batting partnerships of Royal Challengers Bangalore (Virat Kohli  and Chris Gayle lead)
teamBatsmenPartnershipAllOppnAllMatchesPlot(rcb_Allmatches,"Royal Challengers Bangalore",main="Royal Challengers Bangalore")

batsmenPartnership1-2

# Plot of IPL T20 batting partnerships of Kolkata Knight Riders (Gautham Gambhir and Yusuf Pathan head the list)
teamBatsmenPartnershipAllOppnAllMatchesPlot(kkr_Allmatches,"Kolkata Knight Riders",main="Kolkata Knight Riders")

batsmenPartnership1-3

10. Top opposition batting partnerships in IPL Twenty20 matches against all opposing teams

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

# Top Sunrisers Hyderabad IPL T20 partnerships against Kings XI Punjab
teamBatsmenPartnershipAllOppnAllMatchesPlot(sh_Allmatches,"Sunrisers Hyderabad",main="Kings XI Punjab")

batsmenPartnership2-1

# Top Delhi Daredevils T20 partnerships against Deccan Chargers
teamBatsmenPartnershipAllOppnAllMatchesPlot(dd_Allmatches,"Delhi Daredevils",main="Deccan Chargers")

batsmenPartnership2-2

# Top Rajasthan Royals T20 partnerships against Chennai Super Kings 
teamBatsmenPartnershipAllOppnAllMatchesPlot(rr_Allmatches,"Rajasthan Royals",main="Chennai Super Kings")

batsmenPartnership2-3

11. Batsmen vs Bowlers in IPL Twenty20 matches against all opposing teams

The function below gives the top performance of batsmen against the opposing teams

# Top IPL T20 Chennai Super Kings batsmen against bowlers when rank=0
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(csk_Allmatches,"Chennai Super Kings",rank=0)
m
## Source: local data frame [46 x 2]
## 
##         batsman runsScored
##          (fctr)      (dbl)
## 1      SK Raina       3567
## 2      MS Dhoni       2887
## 3    MEK Hussey       1721
## 4       M Vijay       1574
## 5   S Badrinath       1427
## 6  F du Plessis       1081
## 7     ML Hayden       1077
## 8      DR Smith        886
## 9     JA Morkel        812
## 10  BB McCullum        809
## ..          ...        ...
# Performance of IPL T20  Rajasthan Royals batsman in T20 with rank=1 against all other IPL teams. This is Shane Watson for RR
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(rr_Allmatches,"Rajasthan Royals",rank=1,dispRows=30)
m
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##      batsman          bowler  runs
##       (fctr)          (fctr) (dbl)
## 1  SR Watson        M Kartik    94
## 2  SR Watson       RA Jadeja    73
## 3  SR Watson      SL Malinga    68
## 4  SR Watson         P Kumar    66
## 5  SR Watson       PP Chawla    63
## 6  SR Watson        R Ashwin    59
## 7  SR Watson Shakib Al Hasan    56
## 8  SR Watson  M Muralitharan    54
## 9  SR Watson       MM Sharma    50
## 10 SR Watson        DJ Bravo    49
## ..       ...             ...   ...
# Performance of Kolkata Knight Riders batsman in IPL T20 with rank=2 with all other IPL teams. This is Yusuf Pathan with
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(kkr_Allmatches,"Kolkata Knight Riders",rank=2,dispRows=30)
m
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##      batsman          bowler  runs
##       (fctr)          (fctr) (dbl)
## 1  YK Pathan        DW Steyn    75
## 2  YK Pathan        A Mishra    63
## 3  YK Pathan      SL Malinga    57
## 4  YK Pathan   R Vinay Kumar    39
## 5  YK Pathan Harbhajan Singh    36
## 6  YK Pathan       KV Sharma    33
## 7  YK Pathan         B Kumar    32
## 8  YK Pathan     Imran Tahir    27
## 9  YK Pathan       S Aravind    26
## 10 YK Pathan        M Morkel    25
## ..       ...             ...   ...

12. Batsmen vs Bowlers in IPL Twenty20 matches against all other IPL teams (continued)

# The RCB IPL T20 batsmen who has the best performance against Sunrisers Hyderabad bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(matches=sh_Allmatches,theTeam="Royal Challengers Bangalore",rank=1,dispRows=25)
m
## Source: local data frame [18 x 3]
## Groups: batsman [1]
## 
##    batsman          bowler  runs
##     (fctr)          (fctr) (dbl)
## 1  V Kohli       KV Sharma    48
## 2  V Kohli        A Mishra    35
## 3  V Kohli     NLTC Perera    31
## 4  V Kohli         B Kumar    26
## 5  V Kohli        I Sharma    25
## 6  V Kohli        DW Steyn    23
## 7  V Kohli         P Kumar    21
## 8  V Kohli       IK Pathan    16
## 9  V Kohli        CL White    13
## 10 V Kohli        TA Boult    11
## 11 V Kohli  A Ashish Reddy    10
## 12 V Kohli    Ankit Sharma    10
## 13 V Kohli       DJG Sammy     7
## 14 V Kohli   Parvez Rasool     7
## 15 V Kohli       RS Bopara     3
## 16 V Kohli    MC Henriques     2
## 17 V Kohli       GH Vihari     2
## 18 V Kohli Y Venugopal Rao     1
# All the top IPL T20 Delhi Daredevils batsmen against Kings XI Punjab in all of Indian matches
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(kxip_Allmatches,"Delhi Daredevils",rank=0)
m
## Source: local data frame [52 x 2]
## 
##             batsman runsScored
##              (fctr)      (dbl)
## 1          V Sehwag        250
## 2         DA Warner        245
## 3         G Gambhir        179
## 4        KD Karthik        175
## 5        MA Agarwal        128
## 6  DPMD Jayawardene        107
## 7      KP Pietersen        107
## 8           NV Ojha         86
## 9          M Manhas         83
## 10  Y Venugopal Rao         72
## ..              ...        ...
# The best Chennai Super Kings IPL T20 batsman(rank=0) against Delhi Daredevils and his performance against England bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(dd_Allmatches,"Chennai Super Kings",rank=1,dispRows=30)
m
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##     batsman        bowler  runs
##      (fctr)        (fctr) (dbl)
## 1  MS Dhoni     IK Pathan    33
## 2  MS Dhoni    AB Agarkar    30
## 3  MS Dhoni       A Nehra    29
## 4  MS Dhoni Mohammad Asif    21
## 5  MS Dhoni    JD Unadkat    19
## 6  MS Dhoni      M Morkel    17
## 7  MS Dhoni      UT Yadav    16
## 8  MS Dhoni    GD McGrath    14
## 9  MS Dhoni      V Sehwag    14
## 10 MS Dhoni      S Nadeem    14
## ..      ...           ...   ...
# All the top Deccan Chargers IPL T20 batsmen (rank=0) against Kolkata Knight Riders and performances against Australian bowlers
m <-teamBatsmenVsBowlersAllOppnAllMatchesRept(kkr_Allmatches,"Deccan Chargers",rank=0)
m
## Source: local data frame [29 x 2]
## 
##            batsman runsScored
##             (fctr)      (dbl)
## 1     AC Gilchrist        166
## 2         HH Gibbs        145
## 3        RG Sharma        116
## 4         S Dhawan        111
## 5        A Symonds        100
## 6  Y Venugopal Rao         92
## 7         B Chipli         60
## 8     DB Ravi Teja         54
## 9         TL Suman         53
## 10      VVS Laxman         32
## ..             ...        ...

13. IPL Batsmen vs Bowlers Plot in Twenty20 matches against all other IPL teams

The following functions plot the performances of the IPL batsman based on the rank chosen against all other IPL team’s bowlers. Note: The rank has to be >0

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

d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(rcb_Allmatches,"Royal Challengers Bangalore",rank=1,dispRows=50)
d
## Source: local data frame [50 x 3]
## Groups: batsman [1]
## 
##    batsman          bowler  runs
##     (fctr)          (fctr) (dbl)
## 1  V Kohli        UT Yadav   129
## 2  V Kohli        R Ashwin   115
## 3  V Kohli        A Mishra   106
## 4  V Kohli       IK Pathan    92
## 5  V Kohli        DJ Bravo    79
## 6  V Kohli       RA Jadeja    78
## 7  V Kohli       JA Morkel    73
## 8  V Kohli       PP Chawla    64
## 9  V Kohli       SB Jakati    62
## 10 V Kohli Harbhajan Singh    61
## ..     ...             ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

batsmenVsBowler1-1

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        UT Yadav   129
## 2  V Kohli        R Ashwin   115
## 3  V Kohli        A Mishra   106
## 4  V Kohli       IK Pathan    92
## 5  V Kohli        DJ Bravo    79
## 6  V Kohli       RA Jadeja    78
## 7  V Kohli       JA Morkel    73
## 8  V Kohli       PP Chawla    64
## 9  V Kohli       SB Jakati    62
## 10 V Kohli Harbhajan Singh    61
## ..     ...             ...   ...
# The following plot displays the performance of the Chennai Super Kings IPL T20 batsman (rank=2) against all opposition IPL bowlers. This is M S Dhoni for India
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(csk_Allmatches,"Chennai Super Kings",rank=2,dispRows=50)
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

batsmenVsBowler1-2

# Best IPL T20 batsman of Delhi Daredevils against all other IPL  bowlers
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(dd_Allmatches,"Delhi Daredevils",rank=1,dispRows=30)
d
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##     batsman          bowler  runs
##      (fctr)          (fctr) (dbl)
## 1  V Sehwag        RP Singh    88
## 2  V Sehwag Harbhajan Singh    54
## 3  V Sehwag        MM Patel    52
## 4  V Sehwag       JA Morkel    47
## 5  V Sehwag   R Vinay Kumar    47
## 6  V Sehwag  AD Mascarenhas    47
## 7  V Sehwag         P Kumar    46
## 8  V Sehwag       PP Chawla    45
## 9  V Sehwag        R Sharma    43
## 10 V Sehwag         MS Gony    42
## ..      ...             ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

batsmenVsBowler1-3

# Best IPL T20 batsman of Deccan Chargers against all other IPL  bowlers
d <- teamBatsmenVsBowlersAllOppnAllMatchesRept(dc_Allmatches,"Deccan Chargers",rank=1,dispRows=30)
d
## Source: local data frame [30 x 3]
## Groups: batsman [1]
## 
##         batsman      bowler  runs
##          (fctr)      (fctr) (dbl)
## 1  AC Gilchrist     A Nehra    67
## 2  AC Gilchrist   DP Nannes    45
## 3  AC Gilchrist S Sreesanth    40
## 4  AC Gilchrist   JH Kallis    39
## 5  AC Gilchrist    MM Patel    39
## 6  AC Gilchrist   JA Morkel    34
## 7  AC Gilchrist   IK Pathan    34
## 8  AC Gilchrist    A Kumble    34
## 9  AC Gilchrist  AB Agarkar    31
## 10 AC Gilchrist    I Sharma    30
## ..          ...         ...   ...
teamBatsmenVsBowlersAllOppnAllMatchesPlot(d)

batsmenVsBowler1-4

14. Team bowling IPL T20 scorecard against all opposing IPL steams

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

teamBowlingScorecardAllOppnAllMatchesMain(matches=kkr_Allmatches,theTeam="Kolkata Knight Riders")
## Source: local data frame [52 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1        SP Narine    18       0  1289      84
## 2        JH Kallis    20       0  1105      46
## 3  Shakib Al Hasan    18       0   827      43
## 4         R Bhatia    15       0   905      38
## 5         L Balaji    21       0   879      37
## 6    Iqbal Abdulla    20       0   674      32
## 7         AB Dinda    17       0   605      29
## 8        PP Chawla    15       0   572      26
## 9         I Sharma    17       0   862      25
## 10        M Morkel    14       0   573      25
## ..             ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(matches=csk_Allmatches,theTeam="Chennai Super Kings")
## Source: local data frame [44 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1        R Ashwin    20       0  2127      98
## 2        DJ Bravo    17       0  1542      88
## 3       JA Morkel    20       0  2000      83
## 4       MM Sharma    19       0  1208      60
## 5       RA Jadeja    17       0  1346      58
## 6       SB Jakati    18       0  1154      46
## 7  M Muralitharan    16       0   977      41
## 8    DE Bollinger    13       0   662      41
## 9        L Balaji    21       0   809      35
## 10        A Nehra    12       0   591      33
## ..            ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(dc_Allmatches,"Deccan Chargers")
## Source: local data frame [43 x 5]
## 
##           bowler overs maidens  runs wickets
##           (fctr) (int)   (int) (dbl)   (dbl)
## 1        PP Ojha    18       0  1328      66
## 2       RP Singh    18       0  1229      57
## 3       A Mishra    14       0   735      32
## 4       DW Steyn    13       0   584      32
## 5      A Symonds    18       0   633      22
## 6     WPUJC Vaas     8       0   355      22
## 7      RJ Harris    15       0   463      21
## 8   DT Christian    17       0   583      20
## 9  Harmeet Singh    18       0   419      17
## 10     RG Sharma    13       0   339      15
## ..           ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(dd_Allmatches,"Delhi Daredevils")
## Source: local data frame [61 x 5]
## 
##         bowler overs maidens  runs wickets
##         (fctr) (int)   (int) (dbl)   (dbl)
## 1     A Mishra    20       0  1105      54
## 2     UT Yadav    19       0  1314      53
## 3     M Morkel    19       0  1113      52
## 4      A Nehra    16       0   758      41
## 5    IK Pathan    21       0  1191      34
## 6   PJ Sangwan    19       0   782      34
## 7    DP Nannes    17       0   596      31
## 8     S Nadeem    19       0  1046      30
## 9  MF Maharoof    18       0   507      29
## 10 Imran Tahir    13       0   485      26
## ..         ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(kxip_Allmatches,"Kings XI Punjab")
## Source: local data frame [52 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1       PP Chawla    15       0  2188      87
## 2       IK Pathan    18       0  1112      56
## 3         P Awana    21       0  1029      43
## 4         P Kumar    19       0  1152      35
## 5        AR Patel    19       0   797      33
## 6  Sandeep Sharma    14       0   704      32
## 7   Azhar Mahmood    18       0   659      30
## 8     S Sreesanth    18       0   750      28
## 9      MG Johnson    19       0   780      26
## 10      RJ Harris    15       0   584      26
## ..            ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(ktk_Allmatches,"Kochi Tuskers Kerala")
## Source: local data frame [13 x 5]
## 
##              bowler overs maidens  runs wickets
##              (fctr) (int)   (int) (dbl)   (dbl)
## 1     R Vinay Kumar    15       0   335      17
## 2          RP Singh    11       0   345      15
## 3         RA Jadeja    12       0   305       9
## 4          BJ Hodge     7       0    77       8
## 5       S Sreesanth     9       1   206       7
## 6          RV Gomez     7       0   124       5
## 7       NLTC Perera    10       0   111       5
## 8    P Parameswaran     9       0   137       4
## 9    M Muralitharan     5       0   141       2
## 10         RR Powar     7       0   112       2
## 11          B Akhil     2       0    22       0
## 12       P Prasanth     1       0    18       0
## 13 Y Gnaneswara Rao     1       0     7       0
teamBowlingScorecardAllOppnAllMatchesMain(mi_Allmatches,"Mumbai Indians")
## Source: local data frame [59 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1       SL Malinga    21       0  2478     158
## 2  Harbhajan Singh    20       0  2668     118
## 3       KA Pollard    16       0  1614      66
## 4         MM Patel    19       0   862      42
## 5      DS Kulkarni    19       0   825      37
## 6          PP Ojha    16       0   968      32
## 7         DJ Bravo    17       0   719      30
## 8           Z Khan    14       0   630      30
## 9       MG Johnson    11       0   436      22
## 10  MJ McClenaghan    12       0   386      18
## ..             ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(pw_Allmatches,"Pune Warriors")
## Source: local data frame [34 x 5]
## 
##          bowler overs maidens  runs wickets
##          (fctr) (int)   (int) (dbl)   (dbl)
## 1      R Sharma    17       0   854      35
## 2      AB Dinda    17       0   634      28
## 3       B Kumar    20       0   697      24
## 4    WD Parnell    16       1   444      21
## 5     AC Thomas    14       0   406      16
## 6  Yuvraj Singh    10       0   333      15
## 7      MR Marsh    13       0   281      14
## 8    AD Mathews    16       0   407      12
## 9       A Nehra    17       0   402      12
## 10   MN Samuels    14       0   250      10
## ..          ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(rcb_Allmatches,"Royal Challengers Bangalore")
## Source: local data frame [57 x 5]
## 
##           bowler overs maidens  runs wickets
##           (fctr) (int)   (int) (dbl)   (dbl)
## 1  R Vinay Kumar    21       0  1822      83
## 2         Z Khan    15       0  1237      53
## 3       A Kumble    18       0  1040      47
## 4       MA Starc    18       0   693      39
## 5        P Kumar    18       0  1078      37
## 6      YS Chahal    14       0   801      36
## 7       HV Patel    15       0   781      32
## 8       DW Steyn    15       0   654      32
## 9      S Aravind    11       0   548      32
## 10     JH Kallis    16       0  1088      26
## ..           ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(rr_Allmatches,"Rajasthan Royals")
## Source: local data frame [56 x 5]
## 
##           bowler overs maidens  runs wickets
##           (fctr) (int)   (int) (dbl)   (dbl)
## 1     SK Trivedi    19       0  1862      70
## 2      SR Watson    21       0  1633      68
## 3       SK Warne    16       0  1405      60
## 4    JP Faulkner    20       0  1224      49
## 5       MM Patel    20       0   779      39
## 6      KK Cooper    18       0   691      32
## 7        A Singh    14       0   620      31
## 8        SW Tait    19      NA    NA      26
## 9  Sohail Tanvir    12       0   266      24
## 10     YK Pathan    17       0   693      23
## ..           ...   ...     ...   ...     ...
teamBowlingScorecardAllOppnAllMatchesMain(sh_Allmatches,"Sunrisers Hyderabad")
## Source: local data frame [21 x 5]
## 
##          bowler overs maidens  runs wickets
##          (fctr) (int)   (int) (dbl)   (dbl)
## 1       B Kumar    16       0   761      40
## 2     KV Sharma    17       0   905      38
## 3      DW Steyn    17       0   968      33
## 4      A Mishra    16       0   726      29
## 5      I Sharma    18       0   704      20
## 6   NLTC Perera    13       0   453      19
## 7  MC Henriques    15       0   254      15
## 8     DJG Sammy    14       0   321      14
## 9      TA Boult    12       0   236      10
## 10    RS Bopara     7       0   160       8
## ..          ...   ...     ...   ...     ...

15. Team bowling IPL T20 scorecard against all opposing teams (continued)

The function lists the top bowlers of a IPL team (‘matches’) against the opposing teams

# Best Sunrisers Hyderabad bowlers in matches against CSK
teamBowlingScorecardAllOppnAllMatches(sh_Allmatches,'Chennai Super Kings')
## Source: local data frame [14 x 5]
## 
##            bowler overs maidens  runs wickets
##            (fctr) (int)   (int) (dbl)   (dbl)
## 1       KV Sharma    10       1   151       4
## 2         B Kumar     8       0   122       4
## 3        I Sharma     9       0   183       3
## 4        A Mishra     9       0    94       3
## 5     NLTC Perera     1       0    45       3
## 6        TA Boult     5       0    78       2
## 7  A Ashish Reddy     3       0    34       2
## 8       RS Bopara     1       0    29       2
## 9    MC Henriques     4       0    20       2
## 10       DW Steyn     7       0   125       1
## 11      DJG Sammy     4       0    75       0
## 12  Parvez Rasool     1       0    46       0
## 13      IK Pathan     1       0    34       0
## 14        P Kumar     4       0    33       0
# Best Kolkata Knight Riders bowlers in matches against Kings XI Punjab
teamBowlingScorecardAllOppnAllMatches(ktk_Allmatches,'Kings XI Punjab')
## Source: local data frame [7 x 5]
## 
##           bowler overs maidens  runs wickets
##           (fctr) (int)   (int) (dbl)   (dbl)
## 1       RP Singh     4       0    25       4
## 2    S Sreesanth     4       0    38       0
## 3  R Vinay Kumar     3       0    28       0
## 4      RA Jadeja     3       0    27       0
## 5       BJ Hodge     2       0    26       0
## 6 P Parameswaran     2       0    23       0
## 7       RV Gomez     1       0    12       0
# Best Mumbai Indian bowlers in matches against Delhi Daredevils
teamBowlingScorecardAllOppnAllMatches(mi_Allmatches,'Delhi Daredevils')
## Source: local data frame [37 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1       SL Malinga    14       0   271      21
## 2  Harbhajan Singh    17       1   318      17
## 3       KA Pollard    10       0   185       6
## 4       AG Murtaza     5       0    39       6
## 5      DS Kulkarni     9       0   116       5
## 6          A Nehra     6       0    55       4
## 7          PP Ojha    12       0   112       3
## 8    ST Jayasuriya     7       0    93       3
## 9         DJ Bravo     6       0    66       3
## 10      SM Pollock     4       0    49       3
## ..             ...   ...     ...   ...     ...
# Best Royal Challengers Bangalore bowlers in matches against Pune Warriors
teamBowlingScorecardAllOppnAllMatches(rcb_Allmatches,"Pune Warriors")
## Source: local data frame [16 x 5]
## 
##             bowler overs maidens  runs wickets
##             (fctr) (int)   (int) (dbl)   (dbl)
## 1    R Vinay Kumar    12       0   121      10
## 2           Z Khan     6       0    88       4
## 3         CH Gayle     3       0    18       4
## 4         M Kartik     6       0    54       3
## 5         HV Patel     5       0    65       2
## 6       DL Vettori     5       0    57       2
## 7   M Muralitharan     6       0    48       2
## 8         RP Singh     5       0    47       2
## 9     MC Henriques     4       0    44       2
## 10      JD Unadkat     4       0    37       2
## 11       R Rampaul     4       0    21       2
## 12      KP Appanna     5       0    53       1
## 13       S Aravind     4       0    35       1
## 14 J Syed Mohammad     2       0    26       1
## 15        A Mithun     4       0    26       0
## 16      TM Dilshan     1       0    24       0

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

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

# Best Chennai Super Kings IPL T20 bowlers overall  against all other IPL (rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(csk_Allmatches,theTeam="Chennai Super Kings",rank=0)
## Source: local data frame [10 x 2]
## 
##            bowler  runs
##            (fctr) (dbl)
## 1        R Ashwin  2063
## 2       JA Morkel  1917
## 3        DJ Bravo  1486
## 4       RA Jadeja  1320
## 5       MM Sharma  1192
## 6       SB Jakati  1134
## 7  M Muralitharan   928
## 8        SK Raina   888
## 9        L Balaji   781
## 10        MS Gony   654
# Top Chennai Super Kings IPL T20 bowler of India and runs conceded against different opposition batsmen 
(rank=1)
## [1] 1
m <-teamBowlersVsBatsmenAllOppnAllMatchesMain(csk_Allmatches,theTeam="Chennai Super Kings",rank=1)
m
## Source: local data frame [148 x 3]
## Groups: bowler [1]
## 
##      bowler      batsman runsConceded
##      (fctr)       (fctr)        (dbl)
## 1  R Ashwin      V Kohli          115
## 2  R Ashwin   GJ Maxwell           72
## 3  R Ashwin   RV Uthappa           68
## 4  R Ashwin    RG Sharma           59
## 5  R Ashwin    SR Watson           59
## 6  R Ashwin  LMP Simmons           58
## 7  R Ashwin     MS Bisla           52
## 8  R Ashwin     CH Gayle           49
## 9  R Ashwin    DA Warner           48
## 10 R Ashwin AC Gilchrist           46
## ..      ...          ...          ...
# Top Kolkata Knight Riders IPL T20 bowler and runs conceded  against different opposing IPL  batsmen (rank=1)
m <-teamBowlersVsBatsmenAllOppnAllMatchesMain(kkr_Allmatches,theTeam="Kolkata Knight Riders",rank=1)
m
## Source: local data frame [132 x 3]
## Groups: bowler [1]
## 
##       bowler    batsman runsConceded
##       (fctr)     (fctr)        (dbl)
## 1  SP Narine  RG Sharma           62
## 2  SP Narine   SK Raina           58
## 3  SP Narine    WP Saha           52
## 4  SP Narine  JP Duminy           50
## 5  SP Narine  DA Warner           44
## 6  SP Narine MEK Hussey           37
## 7  SP Narine  AM Rahane           33
## 8  SP Narine    V Kohli           29
## 9  SP Narine KD Karthik           27
## 10 SP Narine KA Pollard           26
## ..       ...        ...          ...
# Top IPL T20 bowlers versus batsmen of Delhi Daredevils(rank=0)
teamBowlersVsBatsmenAllOppnAllMatchesMain(dd_Allmatches,theTeam="Delhi Daredevils",rank=0)
## Source: local data frame [10 x 2]
## 
##         bowler  runs
##         (fctr) (dbl)
## 1     UT Yadav  1261
## 2    IK Pathan  1156
## 3     M Morkel  1075
## 4     A Mishra  1072
## 5     S Nadeem  1026
## 6   PJ Sangwan   744
## 7      A Nehra   728
## 8    DP Nannes   558
## 9  MF Maharoof   481
## 10 Imran Tahir   461

17. Team bowlers versus batsmen report (in IPL T20 matches against all opposing team)

#The best IPL T20 bowlers of other IPL teams against Chennai Super Kings
teamBowlersVsBatsmenAllOppnAllMatchesRept(matches=csk_Allmatches,theTeam="Chennai Super Kings",rank=0)
## Source: local data frame [10 x 2]
## 
##             bowler  runs
##             (fctr) (dbl)
## 1  Harbhajan Singh   461
## 2    R Vinay Kumar   435
## 3          P Kumar   421
## 4        PP Chawla   410
## 5        IK Pathan   399
## 6       SL Malinga   380
## 7         RP Singh   353
## 8        JH Kallis   348
## 9          PP Ojha   333
## 10       YK Pathan   293
# Best T20 performer against Mumbai Indians is A Mishra
a <- teamBowlersVsBatsmenAllOppnAllMatchesRept(mi_Allmatches,theTeam="Mumbai Indians",rank=1)
a
## Source: local data frame [24 x 3]
## Groups: bowler [1]
## 
##      bowler      batsman runsConceded
##      (fctr)       (fctr)        (dbl)
## 1  A Mishra   KA Pollard           91
## 2  A Mishra    AT Rayudu           71
## 3  A Mishra SR Tendulkar           55
## 4  A Mishra    RG Sharma           51
## 5  A Mishra    SS Tiwary           26
## 6  A Mishra    AM Rahane           23
## 7  A Mishra     DR Smith           16
## 8  A Mishra  LMP Simmons           16
## 9  A Mishra    JP Duminy           13
## 10 A Mishra     DJ Bravo           11
## ..      ...          ...          ...

18. Team bowlers versus batsmen report (in T20s against all opposing teams continued)

#Top Royal Challengers Bangalore T20 Indian bowlers against Rajasthan Royals
teamBowlersVsBatsmenAllOppnAllMatchesRept(matches=rcb_Allmatches,theTeam="Rajasthan Royals",rank=0)
## Source: local data frame [10 x 2]
## 
##           bowler  runs
##           (fctr) (dbl)
## 1  R Vinay Kumar   252
## 2         Z Khan   134
## 3        P Kumar   115
## 4       A Kumble   106
## 5      S Aravind   101
## 6       MA Starc   100
## 7      JH Kallis    96
## 8      YS Chahal    86
## 9       HV Patel    69
## 10      M Kartik    67
#Top Pune Warriors T20 Indian bowlers against Kings XI Punjab
teamBowlersVsBatsmenAllOppnAllMatchesRept(pw_Allmatches,"Kings XI Punjab",rank=0)
## Source: local data frame [10 x 2]
## 
##          bowler  runs
##          (fctr) (dbl)
## 1      R Sharma   128
## 2      AB Dinda    93
## 3       B Kumar    61
## 4    MN Samuels    50
## 5      MR Marsh    48
## 6      JD Ryder    43
## 7       A Nehra    42
## 8    BAW Mendis    38
## 9     LJ Wright    35
## 10 Yuvraj Singh    32

19. Team bowlers versus batsmen report (in T20s against all opposing teams) plot

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

# Top IPL T20 bowler against Chennai Super Kings (This is Harbhajan Singh)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(csk_Allmatches,theTeam="Chennai Super Kings",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"Chennai Super Kings","Chennai Super Kings")

bowlerVsbatsmen1-1

# Top IPL T20 Indian bowler versus Delhi Daredevils (R Vinay Kumar)
df <- teamBowlersVsBatsmenAllOppnAllMatchesRept(dd_Allmatches,theTeam="Delhi Daredevils",rank=1)
teamBowlersVsBatsmenAllOppnAllMatchesPlot(df,"Delhi Daredevils","Delhi Daredevils")

bowlerVsbatsmen1-2

20. Team Bowler Wicket Kind in Twenty20 matches against all opposing IPL teams

# Top opposition IPL T20  bowlers against Chennai Super Kings and the kind of wickets
teamBowlingWicketKindAllOppnAllMatches(csk_Allmatches,t1="Chennai Super Kings",t2="All")

bowlingWicketkind1-1

# Top opposition IPL T20  bowlers against Royal Challengers Bangalore and the kind of 
# wickets. Get the data frame. Do not plot
m <-teamBowlingWicketKindAllOppnAllMatches(rcb_Allmatches,t1="Royal Challengers Bangalore",t2="All",plot=FALSE)
m
## Source: local data frame [34 x 3]
## Groups: bowler [?]
## 
##       bowler wicketKind     m
##       (fctr)      (chr) (int)
## 1   L Balaji     bowled     6
## 2   L Balaji     caught    10
## 3   L Balaji    run out     2
## 4  JA Morkel     bowled     4
## 5  JA Morkel     caught     6
## 6  JA Morkel        lbw     4
## 7    A Nehra     bowled     5
## 8    A Nehra     caught    14
## 9    A Nehra        lbw     1
## 10   A Nehra    run out     1
## ..       ...        ...   ...
# Top opposition IPL T20  bowlers against Delhi Daredevils and the kind of wickets
teamBowlingWicketKindAllOppnAllMatches(dd_Allmatches,t1="Delhi Daredevils",t2="All")

bowlingWicketkind1-2

21. Team Bowler Wicket Runs in IPL Twenty20 matches against all opposing teams

# Opposition T20 bowlers against Chennai Super Kings and runs conceded
teamBowlingWicketRunsAllOppnAllMatches(csk_Allmatches,t1="Chennai Super Kings",t2="All",plot=TRUE)

bowlingWicketRuns1-1

# Opposition T20 bowlers against Mumbai Indians and runs conceded returned as dataframe
m <-teamBowlingWicketRunsAllOppnAllMatches(mi_Allmatches,t1="Mumbai Indians",t2="All",plot=FALSE)
m
## Source: local data frame [10 x 3]
## 
##           bowler runsConceded wickets
##           (fctr)        (dbl)   (dbl)
## 1       DJ Bravo          299      24
## 2      PP Chawla          348      18
## 3        A Nehra          296      16
## 4       DW Steyn          326      16
## 5      IK Pathan          297      16
## 6      MM Sharma          293      15
## 7  R Vinay Kumar          402      15
## 8      SP Narine          193      14
## 9       RP Singh          182      13
## 10      AB Dinda          292      13
# Top T20 Indian bowlers against Kolkata Knight Riders and runs conceded
teamBowlingWicketRunsAllOppnAllMatches(kkr_Allmatches,t1="Kolkata Knight Riders",t2="All",plot=TRUE)

bowlingWicketRuns1-2

22. Team Bowler Wicket Runs in IPL Twenty20 matches against all opposing teams(continued)

#Top opposition IPL T20 bowlers against Sunrisers Hyderabad
teamBowlingWicketRunsAllOppnAllMatches(sh_Allmatches,t1="Sunrisers Hyderabad",t2="All",plot=TRUE)

bowlingWicketRuns2-1

#Top opposition IPL T20 bowlers against Pune Warriorss
teamBowlingWicketRunsAllOppnAllMatches(pw_Allmatches,t1="Pune Warriors",t2="All",plot=TRUE)

bowlingWicketRuns2-2bowlingWicketRuns2-3

#Top opposition IPL T20 bowlers against Kings XI Punjab
teamBowlingWicketRunsAllOppnAllMatches(kxip_Allmatches,t1="Kings XI Punjab",t2="All",plot=TRUE)

Conclusion

This post included all functions for an IPL team in all IPL T20 matches against all opposing IPL teams. As before the data frames for the IPL 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 and final part of the IPL yorkr package’s handling of IPL T20 will follow soon.

Watch this space!

You may also like

  1. Introducing cricket package yorkr-Part1:Beaten by sheer pace!.
  2. yorkr pads up for the Twenty20s: Part 1- Analyzing team“s match performance
  3. Literacy in India: A deepR dive
  4. Introducing cricketr! : An R package to analyze performances of cricketers
  5. Design principles of scalable distributed systems
  6. OpenCV: Fun with filters and convolution

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)