Fast, tidy Pro Golf data in R
golfastR provides easy access to professional golf data from ESPN with functions to get leaderboards and hole-by-hole scores in tidy data formats ready for analysis. Supports PGA Tour, LIV Golf, LPGA, DP World Tour, and Champions Tour.
Installation
# Install from CRAN
install.packages("golfastr")
# Or install development version from GitHub
# install.packages("pak")
pak::pak("array-carpenter/golfastr")Supported Tours
| Tour | Code | Example |
|---|---|---|
| PGA Tour | "pga" |
load_schedule(2026, tour = "pga") |
| LIV Golf | "liv" |
load_schedule(2026, tour = "liv") |
| LPGA | "lpga" |
load_schedule(2026, tour = "lpga") |
| DP World Tour | "euro" |
load_schedule(2026, tour = "euro") |
| Champions Tour | "champions" |
load_schedule(2026, tour = "champions") |
All functions accept the tour parameter. Default is "pga".
Quick Start
library(golfastr)
# Get the PGA tournament schedule
schedule <- load_schedule(2026)
# Load a tournament leaderboard
sony <- load_leaderboard(2026, "Sony")
# Get hole-by-hole scoring for top 10
holes <- load_holes(2026, "Sony", top_n = 10)
# LIV Golf works the same way
liv_schedule <- load_schedule(2026, tour = "liv")
adelaide <- load_leaderboard(2026, "Adelaide", tour = "liv")Hosted Data
Completed PGA Tour tournaments are served from pre-built data files hosted on GitHub releases, updated daily. This makes loading a full season near-instant and provides hole-by-hole data for the full field, not just the top finishers:
# Loads from hosted data - seconds, not minutes
season <- load_leaderboard(2025)
# Full-field hole-by-hole scoring
holes <- load_holes(2025, "Masters")
# Bypass hosted data for in-progress tournaments
live_lb <- load_leaderboard(2026, "Travelers", live = TRUE)If the hosted data is unavailable (or a tournament is still in progress), both functions automatically fall back to the live ESPN API.
Strokes Gained
Pre-built PGA Tour strokes gained data ships with the package:
# Get all strokes gained data
sg <- load_strokes_gained()
# Look up a specific player
load_strokes_gained("Scheffler")Returns per-round averages for all six SG categories:
| Field | Description |
|---|---|
| sg_putt | Strokes Gained: Putting |
| sg_arg | Strokes Gained: Around the Green |
| sg_app | Strokes Gained: Approach the Green |
| sg_ott | Strokes Gained: Off the Tee |
| sg_t2g | Strokes Gained: Tee to Green |
| sg_total | Strokes Gained: Total |
Core Functions
Tournament Schedule
# Get schedule for a season
schedule <- load_schedule(2026)
# LIV Golf schedule
liv <- load_schedule(2026, tour = "liv")
# Returns: event_id, tournament_name, start_date, end_dateLeaderboards
# Load by tournament name (partial match)
masters <- load_leaderboard(2026, "Masters")
phoenix <- load_leaderboard(2026, "Phoenix")
# Load by event ID
lb <- load_leaderboard(2026, "401703504")
# Load all tournaments for the year
all_lb <- load_leaderboard(2026)
# LIV Golf leaderboard
liv_lb <- load_leaderboard(2026, "Adelaide", tour = "liv")Hole-by-Hole Scoring
# Get scorecards for top finishers
holes <- load_holes(2026, "Sony", top_n = 10)
# Returns: player_id, player_name, round, hole, par, score, score_typePlayer Directory
# Get players from recent tournaments
players <- load_players(2026)Data Schema
Local Storage
Store data locally for faster repeated access:
# Save to RDS (native R format)
save_to_rds(leaderboard_data, file_path = "golf_data.rds")
# Load from RDS
data <- load_from_rds(file_path = "golf_data.rds")
# Or use Parquet for cross-language compatibility (requires arrow)
save_to_parquet(leaderboard_data, file_path = "golf_data.parquet")
data <- load_from_parquet(file_path = "golf_data.parquet")
# Auto-detect format with load_data()
data <- load_data("golf_data.rds")
data <- load_data("golf_data.parquet", tournament = "Masters")Build a Season Database
# Incrementally fetch all tournaments for a season
build_season(2025, file_path = "pga_2025.rds")
# Check progress
check_season(2025, file_path = "pga_2025.rds")Analysis Functions
# Player season summary
player_summary("Scheffler", file_path = "golf_data.rds")
# Compare multiple players
compare_players(c("Scheffler", "McIlroy"), file_path = "golf_data.rds")
# Win leaders
win_leaders(file_path = "golf_data.rds")
# Scoring average leaders
scoring_avg_leaders(file_path = "golf_data.rds")Data Source
Tournament data is sourced from ESPN’s Golf API (https://www.espn.com/golf/). Strokes gained data is sourced from the PGA Tour (https://www.pgatour.com/stats).
