神刀安全网

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

(This article was first published on R – Giga thoughts … , and kindly contributed toR-bloggers)

“It was a puzzling thing. The truth knocks on the door and you say ‘Go away, I ’m looking for the truth,’ and so it goes away. Puzzling.”

“But even though Quality cannot be defined, you know what Quality is!”

“The Buddha, the Godhead, resides quite comfortably in the circuits of a digital computer or the gears of a cycle transmission as he does at the top of a mountain or in the petals of the flower. To think otherwise is to demean the Buddha – which is to demean oneself.”

                Zen and the Art of Motorcycle maintenance - Robert M Pirsig

Introduction

If we were to to extend the last quote from Zen and the Art of Motorcycle Maintenance, by Robert M Pirsig, I think it would be fair to say that the Buddha also comfortably resides in the exquisite backhand cross-court return of Bjorn Borg, to the the graceful arc of the football in a Lionel Messi’s free kick to the smashing cover drive of Sunil Gavaskar.

In this post I continue to introduce my latest cricket package yorkr. This post is a continuation of my earlier post – Introducing cricket package yorkr-Part1:Beaten by sheer pace! . This post deals with Class 2 functions namely the performances of a team in all matches against a single opposition for e.g all matches of India-Australia, Pakistan-West Indies etc. You can clone/fork the code for my package yorkr from Github at yorkr

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

The list of function in Class 2 are

  1. teamBatsmenPartnershiOppnAllMatches()
  2. teamBatsmenPartnershipOppnAllMatchesChart()
  3. teamBatsmenVsBowlersOppnAllMatches()
  4. teamBattingScorecardOppnAllMatches()
  5. teamBowlingPerfOppnAllMatches()
  6. teamBowlersWicketsOppnAllMatches()
  7. teamBowlersVsBatsmenOppnAllMatches()
  8. teamBowlersWicketKindOppnAllMatches()
  9. teamBowlersWicketRunsOppnAllMatches()
  10. plotWinLossBetweenTeams()

1. Install the package from CRAN

install.packages("yorkr_0.0.2.tar.gz",repos = NULL, type="source") library(yorkr) library(plotly) rm(list=ls())

2. Get data for all matches between 2 teams

We can get all matches between any 2 teams using the function below. The dir parameter should point to the folder which RData files of the individual matches. This function creates a data frame of all the matches and also saves the dataframe as RData

setwd("C:/software/cricket-package/york-test/yorkrData/ODI/ODI-matches") matches <- getAllMatchesBetweenTeams("Australia","India",dir=".") dim(matches)
## [1] 67428    25

I have however already saved the matches for all possible combination of opposing countries. The data for these matches for the individual teams/countries can be obtained from Github at in the folder ODI-allmatches-between-two-teams

Note: The dataframe for the different head-to-head matches can be loaded directly into your code. The datframes are 15000+ rows x 25 columns. While I have 10 functions to process the details between teams, feel free to let loose any statistical or machine learning algorithms on the dataframe. So go ahead with any insights that can be gleaned from random forests, ridge regression,SVM classifiers and so on. If you do come up with something interesting, I would appreciate if you could drop me a note. Also please do attribute source to Cricsheet ( http://cricsheet.org ), the package york and my blog Giga thoughts

3. Save data for all matches between all combination of 2 teams

This can be done locally using the function below. You could use this function to combine all matches between any 2 teams into a single dataframe and save it in the current folder. The current implementation expectes 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

#saveAllMatchesBetweenTeams()

4. Load data directly for all matches between 2 teams

As in my earlier post I pick all matches between 2 random teams. I load the data directly from the stored RData files. When we load the Rdata file a “matches” object will be created. This object can be stored for the apporpriate teams as below

setwd("C:/software/cricket-package/york-test/yorkrData/ODI/ODI-allmatches-between-two-teams") load("India-Australia-allMatches.RData") aus_ind_matches <- matches dim(aus_ind_matches)
## [1] 21909    25
load("England-New Zealand-allMatches.RData") eng_nz_matches <- matches dim(eng_nz_matches)
## [1] 15343    25
load("Pakistan-South Africa-allMatches.RData") pak_sa_matches <- matches dim(pak_sa_matches)
## [1] 17083    25
load("Sri Lanka-West Indies-allMatches.RData") sl_wi_matches <- matches dim(sl_wi_matches)
## [1] 4869   25
load("Bangladesh-Ireland-allMatches.RData") ban_ire_matches <-matches dim(ban_ire_matches)
## [1] 1668   25
load("Kenya-Bermuda-allMatches.RData") ken_ber_matches <- matches dim(ken_ber_matches)
## [1] 1518   25
load("Scotland-Canada-allMatches.RData") sco_can_matches <-matches dim(sco_can_matches)
## [1] 1061   25
load("Netherlands-Afghanistan-allMatches.RData") nl_afg_matches <- matches dim(nl_afg_matches)
## [1] 402  25

5. Team Batsmen partnership (all matches with opposition)

This function will create a report of the batting partnerships in the teams. The report can be brief or detailed depending on the parameter ‘report’. The top batsmen in India-Australia clashes are Ricky Ponting from Australia and Mahendra Singh Dhoni of India.

m<- teamBatsmenPartnershiOppnAllMatches(aus_ind_matches,'Australia',report="summary") m
## Source: local data frame [47 x 2] ##  ##       batsman totalRuns ##        (fctr)     (dbl) ## 1  RT Ponting       876 ## 2  MEK Hussey       753 ## 3   GJ Bailey       614 ## 4   SR Watson       609 ## 5   MJ Clarke       607 ## 6   ML Hayden       573 ## 7   A Symonds       536 ## 8    AJ Finch       525 ## 9   SPD Smith       467 ## 10  DA Warner       391 ## ..        ...       ...
m <-teamBatsmenPartnershiOppnAllMatches(aus_ind_matches,'India',report="summary") m
## Source: local data frame [44 x 2] ##  ##         batsman totalRuns ##          (fctr)     (dbl) ## 1      MS Dhoni      1156 ## 2     RG Sharma       918 ## 3  SR Tendulkar       910 ## 4       V Kohli       902 ## 5     G Gambhir       536 ## 6  Yuvraj Singh       524 ## 7      SK Raina       509 ## 8      S Dhawan       471 ## 9      V Sehwag       289 ## 10   RV Uthappa       283 ## ..          ...       ...
m <-teamBatsmenPartnershiOppnAllMatches(aus_ind_matches,'Australia',report="detailed") m <-teamBatsmenPartnershiOppnAllMatches(pak_sa_matches,'Pakistan',report="summary") m
## Source: local data frame [40 x 2] ##  ##            batsman totalRuns ##             (fctr)     (dbl) ## 1    Misbah-ul-Haq       727 ## 2      Younis Khan       657 ## 3    Shahid Afridi       558 ## 4  Mohammad Yousuf       539 ## 5  Mohammad Hafeez       477 ## 6     Shoaib Malik       452 ## 7    Ahmed Shehzad       348 ## 8     Abdul Razzaq       246 ## 9     Kamran Akmal       241 ## 10      Umar Akmal       215 ## ..             ...       ...
m <-teamBatsmenPartnershiOppnAllMatches(eng_nz_matches,'England',report="summary") m
## Source: local data frame [47 x 2] ##  ##           batsman totalRuns ##            (fctr)     (dbl) ## 1         IR Bell       654 ## 2         JE Root       612 ## 3  PD Collingwood       514 ## 4      EJG Morgan       479 ## 5         AN Cook       464 ## 6       IJL Trott       362 ## 7    KP Pietersen       358 ## 8      JC Buttler       287 ## 9         OA Shah       274 ## 10      RS Bopara       222 ## ..            ...       ...
m <-teamBatsmenPartnershiOppnAllMatches(sl_wi_matches,'Sri Lanka',report="summary") m[1:50,]
## Source: local data frame [50 x 2] ##  ##             batsman totalRuns ##              (fctr)     (dbl) ## 1  DPMD Jayawardene       288 ## 2     KC Sangakkara       238 ## 3        TM Dilshan       224 ## 4       WU Tharanga       220 ## 5        AD Mathews       161 ## 6     ST Jayasuriya       160 ## 7       ML Udawatte        87 ## 8   HDRL Thirimanne        67 ## 9       MDKJ Perera        64 ## 10    CK Kapugedera        57 ## ..              ...       ...
m <- teamBatsmenPartnershiOppnAllMatches(ban_ire_matches,"Ireland",report="summary") m
## Source: local data frame [16 x 2] ##  ##             batsman totalRuns ##              (fctr)     (dbl) ## 1   WTS Porterfield       111 ## 2        KJ O'Brien        99 ## 3        NJ O'Brien        75 ## 4         GC Wilson        60 ## 5          AR White        38 ## 6       DT Johnston        36 ## 7           JP Bray        31 ## 8         JF Mooney        28 ## 9          AC Botha        23 ## 10         EC Joyce        16 ## 11      PR Stirling        15 ## 12      GH Dockrell         9 ## 13        WB Rankin         9 ## 14 D Langford-Smith         6 ## 15       EJG Morgan         5 ## 16        AR Cusack         0

6. Team batsmen partnership (all matches with opposition)

This is plotted graphically in the charts below

teamBatsmenPartnershipOppnAllMatchesChart(aus_ind_matches,"India","Australia")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBatsmenPartnershipOppnAllMatchesChart(pak_sa_matches,main="South Africa",opposition="Pakistan")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

m<- teamBatsmenPartnershipOppnAllMatchesChart(eng_nz_matches,"New Zealand",opposition="England",plot=FALSE) m[1:30,]
##          batsman    nonStriker runs ## 1  KS Williamson   LRPL Taylor  354 ## 2    BB McCullum    MJ Guptill  275 ## 3    LRPL Taylor KS Williamson  273 ## 4     MJ Guptill   BB McCullum  227 ## 5    BB McCullum      JD Ryder  212 ## 6     MJ Guptill KS Williamson  196 ## 7  KS Williamson    MJ Guptill  179 ## 8       JD Ryder   BB McCullum  175 ## 9       JDP Oram     SB Styris  153 ## 10   LRPL Taylor    GD Elliott  147 ## 11    GD Elliott   LRPL Taylor  143 ## 12   LRPL Taylor    MJ Guptill  140 ## 13        JM How   BB McCullum  128 ## 14    MJ Guptill   LRPL Taylor  125 ## 15   BB McCullum        JM How  117 ## 16   BB McCullum   LRPL Taylor  116 ## 17     SB Styris      JDP Oram  100 ## 18   LRPL Taylor        JM How   98 ## 19        JM How   LRPL Taylor   98 ## 20      JDP Oram   BB McCullum   84 ## 21   LRPL Taylor     L Vincent   71 ## 22      JDP Oram    DL Vettori   70 ## 23   LRPL Taylor   BB McCullum   61 ## 24     SB Styris        JM How   55 ## 25      DR Flynn     SB Styris   54 ## 26    DL Vettori      JDP Oram   53 ## 27     L Vincent   LRPL Taylor   53 ## 28    MJ Santner   LRPL Taylor   53 ## 29    SP Fleming     L Vincent   52 ## 30        JM How     SB Styris   50
teamBatsmenPartnershipOppnAllMatchesChart(sl_wi_matches,"Sri Lanka","West Indies")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBatsmenPartnershipOppnAllMatchesChart(ban_ire_matches,"Bangladesh","Ireland")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

7. Team batsmen versus bowler (all matches with opposition)

The plots below provide information on how each of the top batsmen fared against the opposition bowlers

teamBatsmenVsBowlersOppnAllMatches(aus_ind_matches,"India","Australia")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBatsmenVsBowlersOppnAllMatches(pak_sa_matches,"South Africa","Pakistan",top=3)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

m <- teamBatsmenVsBowlersOppnAllMatches(eng_nz_matches,"England","New Zealnd",top=10,plot=FALSE) m
## Source: local data frame [157 x 3] ## Groups: batsman [1] ##  ##    batsman       bowler  runs ##     (fctr)       (fctr) (dbl) ## 1  IR Bell JEC Franklin    63 ## 2  IR Bell      SE Bond    13 ## 3  IR Bell MR Gillespie    33 ## 4  IR Bell     NJ Astle     0 ## 5  IR Bell     JS Patel    20 ## 6  IR Bell   DL Vettori    28 ## 7  IR Bell     JDP Oram    48 ## 8  IR Bell    SB Styris    12 ## 9  IR Bell     KD Mills   124 ## 10 IR Bell   TG Southee    84 ## ..     ...          ...   ...
teamBatsmenVsBowlersOppnAllMatches(sl_wi_matches,"Sri Lanka","West Indies")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBatsmenVsBowlersOppnAllMatches(ban_ire_matches,"Bangladesh","Ireland")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

8. Team batsmen versus bowler (all matches with opposition)

The following tables gives the overall performances of the country’s batsmen against the opposition. For India-Australia matches Dhoni, Rohit Sharma and Tendulkar lead the way. For Australia it is Ricky Ponting, M Hussey and GJ Bailey. In South Africa- Pakistan matches it is AB Devilliers, Hashim Amla etc.

a <-teamBattingScorecardOppnAllMatches(aus_ind_matches,main="India",opposition="Australia")
## Total= 8331
a
## Source: local data frame [44 x 5] ##  ##         batsman ballsPlayed fours sixes  runs ##          (fctr)       (int) (int) (int) (dbl) ## 1      MS Dhoni        1406    78    22  1156 ## 2     RG Sharma        1015    73    24   918 ## 3  SR Tendulkar        1157   103     6   910 ## 4       V Kohli         961    87     6   902 ## 5     G Gambhir         677    44     2   536 ## 6  Yuvraj Singh         664    52    11   524 ## 7      SK Raina         536    43    11   509 ## 8      S Dhawan         470    55     6   471 ## 9      V Sehwag         305    42     4   289 ## 10   RV Uthappa         295    29     7   283 ## ..          ...         ...   ...   ...   ...
teamBattingScorecardOppnAllMatches(aus_ind_matches,"Australia","India")
## Total= 9995
## Source: local data frame [47 x 5] ##  ##       batsman ballsPlayed fours sixes  runs ##        (fctr)       (int) (int) (int) (dbl) ## 1  RT Ponting        1107    86     8   876 ## 2  MEK Hussey         816    56     5   753 ## 3   GJ Bailey         578    51    13   614 ## 4   SR Watson         653    81    10   609 ## 5   MJ Clarke         786    45     5   607 ## 6   ML Hayden         660    72     8   573 ## 7   A Symonds         543    43    15   536 ## 8    AJ Finch         617    52     9   525 ## 9   SPD Smith         431    44     7   467 ## 10  DA Warner         385    40     6   391 ## ..        ...         ...   ...   ...   ...
teamBattingScorecardOppnAllMatches(pak_sa_matches,"South Africa","Pakistan")
## Total= 6657
## Source: local data frame [36 x 5] ##  ##           batsman ballsPlayed fours sixes  runs ##            (fctr)       (int) (int) (int) (dbl) ## 1  AB de Villiers        1533   128    23  1423 ## 2         HM Amla         864    88     3   815 ## 3        GC Smith         726    68     3   597 ## 4       JH Kallis         710    40     8   543 ## 5       JP Duminy         620    35     3   481 ## 6       CA Ingram         388    32     1   305 ## 7    F du Plessis         363    30     4   278 ## 8       Q de Kock         336    28     2   270 ## 9       DA Miller         329    20     2   250 ## 10       HH Gibbs         252    33     2   228 ## ..            ...         ...   ...   ...   ...
teamBattingScorecardOppnAllMatches(sl_wi_matches,"West Indies","Sri Lanka")
## Total= 1800
## Source: local data frame [36 x 5] ##  ##          batsman ballsPlayed fours sixes  runs ##           (fctr)       (int) (int) (int) (dbl) ## 1       DM Bravo         353    20     6   265 ## 2      RR Sarwan         315    11     3   205 ## 3     MN Samuels         209    19     5   188 ## 4       CH Gayle         198    18     8   176 ## 5  S Chanderpaul         181     6     7   152 ## 6      AB Barath         162     9     2   125 ## 7       DJ Bravo         139     7     2   102 ## 8       CS Baugh         102     5    NA    78 ## 9    LMP Simmons          78     5     4    67 ## 10     JO Holder          33     5     3    55 ## ..           ...         ...   ...   ...   ...
teamBattingScorecardOppnAllMatches(eng_nz_matches,"England","New Zealand")
## Total= 6472
## Source: local data frame [47 x 5] ##  ##           batsman ballsPlayed fours sixes  runs ##            (fctr)       (int) (int) (int) (dbl) ## 1         IR Bell         871    74     7   654 ## 2         JE Root         651    54     5   612 ## 3  PD Collingwood         619    34    15   514 ## 4      EJG Morgan         445    35    22   479 ## 5         AN Cook         616    49     3   464 ## 6       IJL Trott         421    26     1   362 ## 7    KP Pietersen         481    30     6   358 ## 8      JC Buttler         199    28    11   287 ## 9         OA Shah         323    17     6   274 ## 10      RS Bopara         350    21    NA   222 ## ..            ...         ...   ...   ...   ...
teamBatsmenPartnershiOppnAllMatches(sco_can_matches,"Scotland","Canada")
## Source: local data frame [20 x 2] ##  ##          batsman totalRuns ##           (fctr)     (dbl) ## 1     CS MacLeod       177 ## 2      MW Machan        68 ## 3      CJO Smith        43 ## 4    FRJ Coleman        40 ## 5      RR Watson        14 ## 6     JH Stander        12 ## 7       MA Leask        12 ## 8     RML Taylor        10 ## 9     KJ Coetzer         8 ## 10   GM Hamilton         7 ## 11        RM Haq         7 ## 12    PL Mommsen         6 ## 13     CM Wright         5 ## 14        JD Nel         5 ## 15      MH Cross         4 ## 16     SM Sharif         4 ## 17     JAR Blain         2 ## 18  NFI McCallum         1 ## 19 RD Berrington         1 ## 20     NS Poonia         0

9. Team performances of bowlers (all matches with opposition)

Like the function above the following tables provide the top bowlers of the countries in the matches against the oppoition. In India-Australia matches Ishant Sharma leads, in Pakistan-South Africa matches Shahid Afridi tops and so on.

teamBowlingPerfOppnAllMatches(aus_ind_matches,"India","Australia")
## Source: local data frame [36 x 5] ##  ##             bowler overs maidens  runs wickets ##             (fctr) (int)   (int) (dbl)   (dbl) ## 1         I Sharma    44       1   739      20 ## 2  Harbhajan Singh    40       0   926      15 ## 3        RA Jadeja    39       0   867      14 ## 4        IK Pathan    42       1   702      11 ## 5         UT Yadav    37       2   606      10 ## 6          P Kumar    27       0   501      10 ## 7           Z Khan    33       1   500      10 ## 8      S Sreesanth    34       0   454      10 ## 9         R Ashwin    43       0   684       9 ## 10   R Vinay Kumar    31       1   380       9 ## ..             ...   ...     ...   ...     ...
teamBowlingPerfOppnAllMatches(pak_sa_matches,main="Pakistan",opposition="South Africa")
## Source: local data frame [24 x 5] ##  ##             bowler overs maidens  runs wickets ##             (fctr) (int)   (int) (dbl)   (dbl) ## 1    Shahid Afridi    38       0  1053      17 ## 2      Saeed Ajmal    39       0   658      14 ## 3  Mohammad Hafeez    38       0   774      13 ## 4   Mohammad Irfan    29       0   467      13 ## 5   Iftikhar Anjum    29       1   257      12 ## 6       Wahab Riaz    31       0   534      11 ## 7      Junaid Khan    32       0   429      10 ## 8    Sohail Tanvir    26       1   409       9 ## 9    Shoaib Akhtar    22       1   313       9 ## 10        Umar Gul    25       2   365       7 ## ..             ...   ...     ...   ...     ...
teamBowlingPerfOppnAllMatches(eng_nz_matches,"New Zealand","England")
## Source: local data frame [33 x 5] ##  ##            bowler overs maidens  runs wickets ##            (fctr) (int)   (int) (dbl)   (dbl) ## 1      TG Southee    40       0   684      19 ## 2        KD Mills    36       1   742      17 ## 3      DL Vettori    35       0   561      16 ## 4  MJ McClenaghan    34       0   515      14 ## 5         SE Bond    17       1   205      11 ## 6      GD Elliott    20       0   194      10 ## 7    JEC Franklin    24       0   418       7 ## 8   KS Williamson    21       1   225       7 ## 9        TA Boult    18       2   195       7 ## 10    NL McCullum    30       0   425       6 ## ..            ...   ...     ...   ...     ...
teamBowlingPerfOppnAllMatches(sl_wi_matches,"Sri Lanka","West Indies")
## Source: local data frame [24 x 5] ##  ##             bowler overs maidens  runs wickets ##             (fctr) (int)   (int) (dbl)   (dbl) ## 1       SL Malinga    28       1   280      11 ## 2       BAW Mendis    15       0   267       8 ## 3  KMDN Kulasekara    13       1   185       7 ## 4       AD Mathews    14       0   191       6 ## 5   M Muralitharan    20       1   157       6 ## 6      MF Maharoof     9       2    14       6 ## 7       WPUJC Vaas     7       2    82       5 ## 8       RAS Lakmal     7       0    55       4 ## 9    ST Jayasuriya     1       0    38       4 ## 10    HMRKB Herath    10       1   124       3 ## ..             ...   ...     ...   ...     ...
teamBowlingPerfOppnAllMatches(ken_ber_matches,"Kenya","Bermuda")
## Source: local data frame [9 x 5] ##  ##        bowler overs maidens  runs wickets ##        (fctr) (int)   (int) (dbl)   (dbl) ## 1  JK Kamande    16       0   122       5 ## 2  HA Varaiya    13       1    64       5 ## 3   AS Luseno     6       0    32       4 ## 4  PJ Ongondo     7       0    39       3 ## 5    TM Odoyo     7       0    36       3 ## 6  LN Onyango     7       0    37       2 ## 7   SO Tikolo    18       0    81       1 ## 8 NN Odhiambo    14       1    76       1 ## 9    CO Obuya     4       0    20       0

10. Team bowler’s wickets (all matches with opposition)

This provided a graphical plot of the tables above

teamBowlersWicketsOppnAllMatches(aus_ind_matches,"India","Australia")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBowlersWicketsOppnAllMatches(aus_ind_matches,"Australia","India")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBowlersWicketsOppnAllMatches(pak_sa_matches,"South Africa","Pakistan",top=10)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

m <-teamBowlersWicketsOppnAllMatches(eng_nz_matches,"England","Zealand",plot=FALSE) m
## Source: local data frame [20 x 2] ##  ##            bowler wickets ##            (fctr)   (int) ## 1     JM Anderson      20 ## 2       SCJ Broad      13 ## 3         ST Finn      12 ## 4  PD Collingwood      11 ## 5        GP Swann      10 ## 6   RJ Sidebottom       8 ## 7       CR Woakes       8 ## 8      A Flintoff       7 ## 9     LE Plunkett       6 ## 10      AU Rashid       6 ## 11      BA Stokes       6 ## 12     MS Panesar       5 ## 13      LJ Wright       4 ## 14     TT Bresnan       4 ## 15      DJ Willey       4 ## 16    JC Tredwell       3 ## 17    CT Tremlett       2 ## 18      RS Bopara       2 ## 19      CJ Jordan       2 ## 20        J Lewis       1
teamBowlersWicketsOppnAllMatches(ban_ire_matches,"Bangladesh","Ireland",top=7)

11. Team bowler vs batsmen (all matches with opposition)

These plots show how the bowlers fared against the batsmen. It shows which of the opposing teams batsmen were able to score the most runs

teamBowlersVsBatsmenOppnAllMatches(aus_ind_matches,'India',"Australia",top=5)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBowlersVsBatsmenOppnAllMatches(pak_sa_matches,"Pakistan","South Africa",top=3)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBowlersVsBatsmenOppnAllMatches(eng_nz_matches,"England","New Zealand")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

teamBowlersVsBatsmenOppnAllMatches(eng_nz_matches,"New Zealand","England")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

12. Team bowler’s wicket kind (caught,bowled,etc) (all matches with opposition)

The charts below show the wicket kind taken by the bowler (caught, bowled, lbw etc)

teamBowlersWicketKindOppnAllMatches(aus_ind_matches,"India","Australia",plot=TRUE)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

m <- teamBowlersWicketKindOppnAllMatches(aus_ind_matches,"Australia","India",plot=FALSE) m[1:30,]
##        bowler        wicketKind wicketPlayerOut runs ## 1  GD McGrath            caught    SR Tendulkar   69 ## 2   SR Watson            caught        D Mongia  532 ## 3  MG Johnson               lbw        V Sehwag 1020 ## 4       B Lee            caught        R Dravid  671 ## 5       B Lee            bowled          M Kaif  671 ## 6  NW Bracken            caught        SK Raina  429 ## 7  GD McGrath            caught       IK Pathan   69 ## 8  NW Bracken               lbw        MS Dhoni  429 ## 9  MG Johnson               lbw    SR Tendulkar 1020 ## 10 MG Johnson            bowled       G Gambhir 1020 ## 11   SR Clark            caught    SR Tendulkar  254 ## 12   JR Hopes            caught    Yuvraj Singh  346 ## 13   SR Clark               lbw      RV Uthappa  254 ## 14    GB Hogg            caught        R Dravid  427 ## 15  MJ Clarke           run out       IK Pathan  212 ## 16  MJ Clarke           stumped Harbhajan Singh  212 ## 17  MJ Clarke            bowled        RR Powar  212 ## 18    GB Hogg            caught          Z Khan  427 ## 19    GB Hogg            caught        MS Dhoni  427 ## 20      B Lee               lbw       G Gambhir  671 ## 21 MG Johnson               lbw      RV Uthappa 1020 ## 22      B Lee            caught        R Dravid  671 ## 23    GB Hogg            bowled    SR Tendulkar  427 ## 24      B Lee            caught        MS Dhoni  671 ## 25   JR Hopes            caught       RG Sharma  346 ## 26    GB Hogg               lbw       IK Pathan  427 ## 27 MG Johnson            bowled    Yuvraj Singh 1020 ## 28    GB Hogg caught and bowled          Z Khan  427 ## 29   SR Clark            bowled     S Sreesanth  254 ## 30   JR Hopes            caught      SC Ganguly  346
teamBowlersWicketKindOppnAllMatches(sl_wi_matches,"Sri Lanka",'West Indies',plot=TRUE)

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

13. Team bowler’s wicket taken and runs conceded (all matches with opposition)

teamBowlersWicketRunsOppnAllMatches(aus_ind_matches,"India","Australia")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

m <-teamBowlersWicketRunsOppnAllMatches(pak_sa_matches,"Pakistan","South Africa",plot=FALSE) m[1:30,]
## Source: local data frame [30 x 5] ##  ##             bowler overs maidens  runs wickets ##             (fctr) (int)   (int) (dbl)   (dbl) ## 1         Umar Gul    25       2   365       7 ## 2   Iftikhar Anjum    29       1   257      12 ## 3     Yasir Arafat     5       0    33       1 ## 4     Abdul Razzaq    16       0   290       4 ## 5  Mohammad Hafeez    38       0   774      13 ## 6    Shahid Afridi    38       0  1053      17 ## 7     Shoaib Malik    18       0   219       4 ## 8    Sohail Tanvir    26       1   409       9 ## 9     Abdur Rehman    25       0   301       4 ## 10   Mohammad Asif    10       1   204       2 ## ..             ...   ...     ...   ...     ...

14. Plot of wins vs losses between teams.

setwd("C:/software/cricket-package/york-test/yorkrData/ODI/ODI-matches") plotWinLossBetweenTeams("India","Sri Lanka")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

plotWinLossBetweenTeams('Pakistan',"South Africa",".")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

plotWinLossBetweenTeams('England',"New Zealand",".")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

plotWinLossBetweenTeams("Australia","West Indies",".")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

plotWinLossBetweenTeams('Bangladesh',"Zimbabwe",".")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

plotWinLossBetweenTeams('Scotland',"Ireland",".")

Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

Conclusion

This post included all functions for all matches between any 2 opposing countries. As before the data frames 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.

There are 2 more posts required for the introduction of MY yorkr package.So, Hasta la vista, baby! I’ll be back!

Also see

You may also like

  1. Introducing cricketr! : An R package to analyze performances of cricketers
  2. Cricket analytics with cricketr
  3. cricketr adapts to the Twenty20 International!
  4. The making of Total Control Android game
  5. De-blurring revisited with Wiener filter using OpenCV
  6. Rock N’ Roll with Bluemix, Cloudant & NodeExpress

Introducing cricket package yorkr: Part 2-Trapped leg before wicket! Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Introducing cricket package yorkr: Part 2-Trapped leg before wicket!

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮