[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.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Introduction
This post ranks IPL batsmen and bowlers post IPL 2020 season based on my R package yorkr. To know more about yorkr see Revisting R package yorkr, Analysis of IPL T20 matches with yorkr templates and others posts on this R package in Index of posts
library(yorkr)
1. Convert YAML files to match data
Convert all the match data as YAML file into .RData
#convertAllYaml2RDataframesT20("ipl","IPLMatches")
2. Rank the IPL Batsmen post IPL 2020
The function below ranks the IPL batsmen post IPL 2020. Note: We can specify the minimum number of matches that should have played by the batsmen for the ranking. By varying this parameter we can identify upcoming stars versus those who are more consistent.
dir="/Users/tvganesh/backup/software/cricket-package/yorkr-cricsheet/ipl2020/IPLMatches" odir="/Users/tvganesh/backup/software/cricket-package/yorkr-cricsheet/ipl2020/IPLBattingBowlingDetails" rankIPLBatsmen(dir=dir,odir=odir,minMatches=60) ## [1] "Chennai Super Kings" ## [1] "Delhi Capitals" ## [1] "Deccan Chargers" ## [1] "Delhi Daredevils" ## [1] "Kings XI Punjab" ## [1] "Kochi Tuskers Kerala" ## [1] "Kolkata Knight Riders" ## [1] "Mumbai Indians" ## [1] "Pune Warriors" ## [1] "Rajasthan Royals" ## [1] "Royal Challengers Bangalore" ## [1] "Sunrisers Hyderabad" ## [1] "Gujarat Lions" ## [1] "Rising Pune Supergiants" ## [1] "Chennai Super Kings-BattingDetails.RData" ## [1] "Delhi Capitals-BattingDetails.RData" ## [1] "Deccan Chargers-BattingDetails.RData" ## [1] "Delhi Daredevils-BattingDetails.RData" ## [1] "Kings XI Punjab-BattingDetails.RData" ## [1] "Kochi Tuskers Kerala-BattingDetails.RData" ## [1] "Kolkata Knight Riders-BattingDetails.RData" ## [1] "Mumbai Indians-BattingDetails.RData" ## [1] "Pune Warriors-BattingDetails.RData" ## [1] "Rajasthan Royals-BattingDetails.RData" ## [1] "Royal Challengers Bangalore-BattingDetails.RData" ## [1] "Sunrisers Hyderabad-BattingDetails.RData" ## [1] "Gujarat Lions-BattingDetails.RData" ## [1] "Rising Pune Supergiants-BattingDetails.RData" ## # A tibble: 65 x 4 ## batsman matches meanRuns meanSR ## <chr> <int> <dbl> <dbl> ## 1 DA Warner 146 37.5 128. ## 2 CH Gayle 132 36.4 134. ## 3 SE Marsh 67 35.9 120. ## 4 KL Rahul 73 34.2 126. ## 5 RR Pant 68 31.8 133. ## 6 V Kohli 190 31.6 118. ## 7 AB de Villiers 155 30.5 136. ## 8 F du Plessis 79 30.4 118. ## 9 S Dhawan 174 30.0 115. ## 10 Q de Kock 64 29.8 119. ## # … with 55 more rows rankIPLBatsmen(dir=dir,odir=odir,minMatches=70) ## [1] "Chennai Super Kings" ## [1] "Delhi Capitals" ## [1] "Deccan Chargers" ## [1] "Delhi Daredevils" ## [1] "Kings XI Punjab" ## [1] "Kochi Tuskers Kerala" ## [1] "Kolkata Knight Riders" ## [1] "Mumbai Indians" ## [1] "Pune Warriors" ## [1] "Rajasthan Royals" ## [1] "Royal Challengers Bangalore" ## [1] "Sunrisers Hyderabad" ## [1] "Gujarat Lions" ## [1] "Rising Pune Supergiants" ## [1] "Chennai Super Kings-BattingDetails.RData" ## [1] "Delhi Capitals-BattingDetails.RData" ## [1] "Deccan Chargers-BattingDetails.RData" ## [1] "Delhi Daredevils-BattingDetails.RData" ## [1] "Kings XI Punjab-BattingDetails.RData" ## [1] "Kochi Tuskers Kerala-BattingDetails.RData" ## [1] "Kolkata Knight Riders-BattingDetails.RData" ## [1] "Mumbai Indians-BattingDetails.RData" ## [1] "Pune Warriors-BattingDetails.RData" ## [1] "Rajasthan Royals-BattingDetails.RData" ## [1] "Royal Challengers Bangalore-BattingDetails.RData" ## [1] "Sunrisers Hyderabad-BattingDetails.RData" ## [1] "Gujarat Lions-BattingDetails.RData" ## [1] "Rising Pune Supergiants-BattingDetails.RData" ## # A tibble: 51 x 4 ## batsman matches meanRuns meanSR ## <chr> <int> <dbl> <dbl> ## 1 DA Warner 146 37.5 128. ## 2 CH Gayle 132 36.4 134. ## 3 KL Rahul 73 34.2 126. ## 4 V Kohli 190 31.6 118. ## 5 AB de Villiers 155 30.5 136. ## 6 F du Plessis 79 30.4 118. ## 7 S Dhawan 174 30.0 115. ## 8 AM Rahane 124 29.6 105. ## 9 SS Iyer 77 29.3 111. ## 10 G Gambhir 155 29 110. ## # … with 41 more rows
3. Rank IPL bowlers post IPL 2020
The function ranks IPL bowlers post IPL 2020. We can specify the minimum number of matches that should have been played by the bowlers
dir="/Users/tvganesh/backup/software/cricket-package/yorkr-cricsheet/ipl2020/IPLMatches" odir="/Users/tvganesh/backup/software/cricket-package/yorkr-cricsheet/ipl2020/IPLBattingBowlingDetails" rankIPLBowlers(dir=dir,odir=odir,minMatches=60) ## [1] "Chennai Super Kings" ## [1] "Delhi Capitals" ## [1] "Deccan Chargers" ## [1] "Delhi Daredevils" ## [1] "Kings XI Punjab" ## [1] "Kochi Tuskers Kerala" ## [1] "Kolkata Knight Riders" ## [1] "Mumbai Indians" ## [1] "Pune Warriors" ## [1] "Rajasthan Royals" ## [1] "Royal Challengers Bangalore" ## [1] "Sunrisers Hyderabad" ## [1] "Gujarat Lions" ## [1] "Rising Pune Supergiants" ## [1] "Chennai Super Kings-BowlingDetails.RData" ## [1] "Delhi Capitals-BowlingDetails.RData" ## [1] "Deccan Chargers-BowlingDetails.RData" ## [1] "Delhi Daredevils-BowlingDetails.RData" ## [1] "Kings XI Punjab-BowlingDetails.RData" ## [1] "Kochi Tuskers Kerala-BowlingDetails.RData" ## [1] "Kolkata Knight Riders-BowlingDetails.RData" ## [1] "Mumbai Indians-BowlingDetails.RData" ## [1] "Pune Warriors-BowlingDetails.RData" ## [1] "Rajasthan Royals-BowlingDetails.RData" ## [1] "Royal Challengers Bangalore-BowlingDetails.RData" ## [1] "Sunrisers Hyderabad-BowlingDetails.RData" ## [1] "Gujarat Lions-BowlingDetails.RData" ## [1] "Rising Pune Supergiants-BowlingDetails.RData" ## # A tibble: 21 x 4 ## bowler matches totalWickets meanER ## <chr> <int> <dbl> <dbl> ## 1 SL Malinga 120 184 6.99 ## 2 SP Narine 117 143 6.82 ## 3 Harbhajan Singh 131 134 7.11 ## 4 DJ Bravo 91 125 8.20 ## 5 YS Chahal 97 124 7.73 ## 6 B Kumar 90 121 7.40 ## 7 JJ Bumrah 91 119 7.35 ## 8 R Ashwin 92 98 6.81 ## 9 RA Jadeja 102 91 8.04 ## 10 PP Chawla 85 87 8.02 ## # … with 11 more rows rankIPLBowlers(dir=dir,odir=odir,minMatches=50) ## [1] "Chennai Super Kings" ## [1] "Delhi Capitals" ## [1] "Deccan Chargers" ## [1] "Delhi Daredevils" ## [1] "Kings XI Punjab" ## [1] "Kochi Tuskers Kerala" ## [1] "Kolkata Knight Riders" ## [1] "Mumbai Indians" ## [1] "Pune Warriors" ## [1] "Rajasthan Royals" ## [1] "Royal Challengers Bangalore" ## [1] "Sunrisers Hyderabad" ## [1] "Gujarat Lions" ## [1] "Rising Pune Supergiants" ## [1] "Chennai Super Kings-BowlingDetails.RData" ## [1] "Delhi Capitals-BowlingDetails.RData" ## [1] "Deccan Chargers-BowlingDetails.RData" ## [1] "Delhi Daredevils-BowlingDetails.RData" ## [1] "Kings XI Punjab-BowlingDetails.RData" ## [1] "Kochi Tuskers Kerala-BowlingDetails.RData" ## [1] "Kolkata Knight Riders-BowlingDetails.RData" ## [1] "Mumbai Indians-BowlingDetails.RData" ## [1] "Pune Warriors-BowlingDetails.RData" ## [1] "Rajasthan Royals-BowlingDetails.RData" ## [1] "Royal Challengers Bangalore-BowlingDetails.RData" ## [1] "Sunrisers Hyderabad-BowlingDetails.RData" ## [1] "Gujarat Lions-BowlingDetails.RData" ## [1] "Rising Pune Supergiants-BowlingDetails.RData" ## # A tibble: 28 x 4 ## bowler matches totalWickets meanER ## <chr> <int> <dbl> <dbl> ## 1 SL Malinga 120 184 6.99 ## 2 SP Narine 117 143 6.82 ## 3 Harbhajan Singh 131 134 7.11 ## 4 DJ Bravo 91 125 8.20 ## 5 YS Chahal 97 124 7.73 ## 6 B Kumar 90 121 7.40 ## 7 JJ Bumrah 91 119 7.35 ## 8 R Ashwin 92 98 6.81 ## 9 RA Jadeja 102 91 8.04 ## 10 PP Chawla 85 87 8.02 ## # … with 18 more rows
- Designing a Social Web Portal
- ntroducing QCSimulator: A 5-qubit quantum computing simulator in R
- Understanding Neural Style Transfer with Tensorflow and Keras
- Big Data-5: kNiFi-ing through cricket data with yorkpy
- Programming languages in layman’s language
To see all posts click Index of posts
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.