Given a table representing all wickets taken in a particular set of matches, return a table of the bowler-batter pairs that occur most commonly.
The input table will have three variables: Batter, Bowler, and Dismissal, representing the batter dismissed, the bowler of the delivery when the wicket fell, and the type of dismissal, respectively. The dismissal will be one of the set: "bowled", "caught", "caught and bowled", "hit wicket", "lbw", "run out", "stumped". Note that run outs are included in the list of wickets. However, because they are not credited to the bowler, your function should not count these.
The output table should have three variables: Batter, Bowler, and NumberOfDismissals. Each row of the table should represent a unique combination of bowler and batter, all with the same value of NumberOfDismissals (which should be the maximum of all pairs in the data set).
For example,
bt = ["Ben";"Matt";"Renee";"Renee";"Ben";"Ned";"Ben";"Renee"];
bw = ["Ned";"Renee";"Ned";"Ben";"Ned";"Matt";"Renee";"Ned"];
w = ["hit wicket";"lbw";"bowled";"caught";"lbw";"stumped";"run out";"caught"];
wickets = table(bt,bw,w,'VariableNames',["Batter","Bowler","Dismissal"])
wickets =
8×3 table
Batter Bowler Dismissal
_______ _______ ____________
"Ben" "Ned" "hit wicket"
"Matt" "Renee" "lbw"
"Renee" "Ned" "bowled"
"Renee" "Ben" "caught"
"Ben" "Ned" "lbw"
"Ned" "Matt" "stumped"
"Ben" "Renee" "run out"
"Renee" "Ned" "caught"
pairs = whosyourbunny(wickets)
pairs =
2×3 table
Batter Bowler NumberOfDismissals
_______ ______ __________________
"Ben" "Ned" 2
"Renee" "Ned" 2
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers22
Suggested Problems
-
Given two arrays, find the maximum overlap
1792 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
519 Solvers
-
Determine the number of odd integers in a vector
838 Solvers
-
Check that number is whole number
5420 Solvers
-
886 Solvers
More from this Author35
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!