Problem 56528. Cricket - Most Frequent Bowler-Batter Wicket Combinations
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 commentsProblem Recent Solvers18
Suggested Problems
-
543 Solvers
-
101 Solvers
-
1856 Solvers
-
8762 Solvers
-
1409 Solvers
More from this Author22
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!