Get aggregated batting statistics with flexible filters. If batter_id is provided, returns stats for that player. If omitted, returns stats for all batters matching the filters (grouped by batter).
Usage
query_batter_stats(
batter_id = NULL,
bowler_id = NULL,
match_type = NULL,
season = NULL,
venue = NULL,
city = NULL,
country = NULL,
event = NULL,
date_range = NULL,
batting_team = NULL,
bowling_team = NULL,
min_balls = 0,
db_path = NULL
)Arguments
- batter_id
Character. The batter to get stats for. If NULL, returns stats for all batters matching other filters.
- bowler_id
Character. Filter to only deliveries from this bowler (for head-to-head)
- match_type
Character. Filter by match type (e.g., "t20", "odi", "test")
- season
Character or numeric. Filter by season
- venue
Character. Filter by venue/stadium (partial match)
- city
Character. Filter by city (partial match)
- country
Character. Filter by country (uses venue-to-country mapping)
- event
Character. Filter by event name (partial match)
- date_range
Date vector of length 2. c(start_date, end_date)
- batting_team
Character. Filter by batting team
- bowling_team
Character. Filter by bowling team
- min_balls
Integer. Minimum balls faced to include (default 0)
- db_path
Character. Database path
Value
Data frame with batting statistics:
batter_id - Player identifier
balls_faced - Total balls faced
runs_scored - Total runs scored
dismissals - Times dismissed
dots - Dot balls (0 runs)
fours - Number of fours
sixes - Number of sixes
batting_average - Runs per dismissal
runs_per_ball - Runs per ball faced
strike_rate - Runs per 100 balls
wicket_pct - Dismissal percentage per ball
Examples
if (FALSE) { # \dontrun{
# Single player stats
query_batter_stats("V Kohli", match_type = "t20")
# Head-to-head vs specific bowler
query_batter_stats("V Kohli", bowler_id = "J Bumrah")
# All batters in Test cricket (min 100 balls)
query_batter_stats(match_type = "test", min_balls = 100)
# All batters in IPL
query_batter_stats(event = "Indian Premier League", min_balls = 50)
# All batters in Australia
query_batter_stats(country = "Australia", match_type = "test", min_balls = 100)
} # }
