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
-
2988 Solvers
-
3281 Solvers
-
317 Solvers
-
Create a vector whose elements depend on the previous element
680 Solvers
-
1402 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!