Title: | Useful Functions for Cricket Analysis |
Version: | 1.0.1 |
Description: | Helping to calculate cricket specific problems in a tidy & simple manner. |
License: | MIT + file LICENSE |
Imports: | magrittr, rlang |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.0 |
Depends: | R (≥ 2.10) |
LazyData: | true |
URL: | https://github.com/lukelockley/howzatR |
BugReports: | https://github.com/lukelockley/howzatR/issues |
NeedsCompilation: | no |
Packaged: | 2022-09-09 13:56:45 UTC; Luke |
Author: | Luke Lockley |
Maintainer: | Luke Lockley <luke.lockley@btinternet.com> |
Repository: | CRAN |
Date/Publication: | 2022-09-09 14:32:56 UTC |
howzatR: Useful Functions for Cricket Analysis
Description
Helping to calculate cricket specific problems in a tidy & simple manner.
Author(s)
Maintainer: Luke Lockley luke.lockley@btinternet.com (ORCID)
See Also
Useful links:
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling rhs(lhs)
.
Convert Balls to Overs (Six Ball)
Description
Convert numbers of balls as it equates in terms of six ball overs.
Usage
balls_to_overs(balls)
Arguments
balls |
number of balls bowled/faced. |
Value
number of six ball overs this equates too.
Examples
balls_to_overs(balls = 6)
balls_to_overs(balls = 17)
Batters Average
Description
Calculates a batter's average over a number of innings.
Usage
bat_avg(runs_scored, no_dismissals)
Arguments
runs_scored |
A singular value of the runs scored by a batter. |
no_dismissals |
A singular value of the number of times a batters has been dismissed within those innings. |
Value
A singular value showing the batter's average.
Additional Information
A batting average is the number of runs divided by the number of times a batters is dismissed. Batters who remain not out at the end of an innings don't have that innings count towards the number of dismissals. The higher average typically indicates a higher quality player. More info here.
Examples
bat_avg(runs_scored = 568, no_dismissals = 9)
total_runs <- sum(c(45, 123, 56, 12, 192, 34, 78, 3, 25))
bat_avg(runs_scored = total_runs, no_dismissals = 9)
Batters Dataset
Description
A dataset containing basic data about batters
Usage
bat_raw_df
Format
A data frame with 3 rows and 5 variables:
- Player
Name of Player
- Inns
Numbers of Innings undertaken by Player
- NO
Numbers of Not Outs by Player
- Runs_Scored
Numbers of Runs Scored by Player
- Balls_Faced
Numbers of Balls Faced by Player
Batters Strike Rate
Description
Calculates a batter's strike rate over a number of innings.
Usage
bat_sr(runs_scored, balls_faced)
Arguments
runs_scored |
A singular value of the runs scored by a batter. |
balls_faced |
A singular value of balls faced by a batter.
Overs can be converted into |
Value
A singular value showing the batter's strike rate per 100 Balls.
Additional Information
A batting strike rate is the average number of runs scored per 100 balls. For example, a strike rate of 135 implies a batter would score 135 runs in a 100 balls. A higher number indicates the batter scores at faster rate. More info here.
Examples
bat_sr(runs_scored = 568, balls_faced = 600)
total_runs <- sum(c(45, 123, 56, 12, 192, 34, 78, 3, 25))
total_balls <- sum(c(50, 120, 78, 3, 226, 36, 45, 12, 30))
bat_sr(
runs_scored = total_runs,
balls_faced = total_balls
)
Bowler Average
Description
Calculates bowlers' average number of runs per wicket taken across overs bowled.
Usage
bowl_avg(runs_conceded, wickets_taken)
Arguments
runs_conceded |
total runs conceded by bowler across the overs bowled. |
wickets_taken |
total wickets taken across the overs bowled. |
Value
Average number of runs per wicket taken across overs bowled.
Additional Information
A bowling average is the average number of runs conceded for wicket taken. A value of 15 indicates an average of
15 runs were conceded per wicket taken. The lower the value, the better the average; the reserve of bat_avg
More info here.
Examples
bowl_avg(runs_conceded = 50, wickets_taken = 6)
bowl_avg(runs_conceded = 341, wickets_taken = 13)
Bowler Economy Rate
Description
Calculates bowlers' economy rate over six ball overs, five ball sets or per hundred balls.
Usage
bowl_econ(balls_bowled, runs_conceded, type = "overs")
Arguments
balls_bowled |
number of balls bowled. Data in terms of six ball overs,
please convert to |
runs_conceded |
total runs conceded by bowler across the overs, sets or per hundred balls bowled. |
type |
whether we are calculating economy over six ball overs, sets or per hundred balls bowled. Options "overs", "sets", "per_100". Defaults to overs |
Value
Economy rate across the number of overs, sets or per hundred balls bowled.
Additional Information
Bowling economy rate is average number of runs scored per over or sets bowled.
If using overs, a value of 9.5 indicates an average of 9.5 runs are scored per six ball over bowled.
If using sets, a value of 9.5 indicates an average of 9.5 runs are scored per five ball set bowled.
If using here, a value of 9.5 indicates an average of 9.5 runs are scored per hundred balls bowled. This the official statistic used by The Hundred.
The higher the number the more detrimental is for the bowler. Runs scored through byes & leg byes are excluded from runs conceded by the bowler, however wides and no-balls are included in the bowler's figures.
More info here.
Examples
bowl_econ(balls_bowled = 60, runs_conceded = 45)
bowl_econ(
balls_bowled = overs_to_balls(overs = 7.1),
runs_conceded = 26,
type = "overs"
)
bowl_econ(balls_bowled = 30, runs_conceded = 35, type = "sets")
bowl_econ(balls_bowled = 22, runs_conceded = 19, type = "per_100")
Bowling Dataset
Description
A dataset containing basic data about bowlers
Usage
bowl_raw_df
Format
A data frame with 3 rows and 4 variables:
- Player
Name of Player
- Balls_Bowled
Numbers of Balls Bowled by Player
- Runs_Conceded
Numbers of Runs Conceded by Player
- Wickets
Numbers of Wickets taken by Player
Bowler Strike Rate
Description
Calculates bowlers' number of balls per wicket taken across overs bowled.
Usage
bowl_sr(balls_bowled, wickets_taken)
Arguments
balls_bowled |
number of balls bowled. Data in terms of six ball overs.
please convert to |
wickets_taken |
total wickets taken across the overs bowled. |
Value
Number of balls per wicket taken across overs bowled.
Additional Information
A bowling strike rate is defined as the number of legal balls per wicket taken.
For example a value of 20 indicates 20 balls bowled are scored per wicket. This the reverse of
bat_sr
where the lower the number the better.
More info here.
Examples
bowl_sr(balls_bowled = 3830, wickets_taken = 112)
bowl_sr(balls_bowled = overs_to_balls(overs = 1651.2), wickets_taken = 243)
Convert Overs (Six Ball) to Balls
Description
Convert Overs (Six Ball) to Balls
Usage
overs_to_balls(overs)
Arguments
overs |
number of six ball overs bowled/faced. |
Value
number of six ball overs this equates too.
Examples
overs_to_balls(overs = 8.2)
overs_to_balls(overs = 10)