fix(statcast): recognize Savant's miss_distance column (#408) - #412
Merged
Merged
Conversation
This was referenced Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Table of Contents generated with DocToc
Summary
statcast_search()now returns Baseball Savant'smiss_distancecolumn (the bat-tracking swing-and-miss distance) and stops silently mislabeling the columns that follow it.Type of Change
feat-- New feature (new endpoint wrapper, new exported function)fix-- Bug fix (non-breaking change that fixes an issue)docs-- Documentation only (roxygen, README, vignettes, NEWS)test-- Adding or updating testsrefactor-- Code change that neither fixes a bug nor adds a featurechore-- Tooling, build, or maintenance changeperf-- Performance improvementRelated Issues
Closes #408
Background & Context
Source: Baseball Savant (
statcast_search()/scrape_statcast_savant*()).The earlier hardening (#337/#354/#371/#390) fixed the
Can't assign 118 names to a 119-column data.tablecrash by assigning the canonical column names positionally and letting any extra columns pass through. That logic only self-heals when Savant appends a column at the end. Savant instead insertedmiss_distancemid-frame at position 93, betweenswing_lengthandestimated_slg_using_speedangle. So the positional rename labeled column 93 (realmiss_distancedata) asestimated_slg_using_speedangleand shifted all 26 columns after it one position off:miss_distancenever appeared, and the trailing bat-tracking columns were silently mislabeled (it even produced a duplicateintercept_ball_minus_batter_pos_y_inches, whichprocess_statcast_payload()then dropped). That matches #408: "downloads without the error, but there's nomiss_distancecolumn."Changes Made
R/sc_statcast_search.R(statcast_search)"miss_distance"intostatcast_columnsat position 93 (afterswing_length); add@returnrow for it; add a comment explaining that mid-frame inserts must be placed in the canonical vectorman/statcast_search.Rd@returntable row viadevtools::document()(roxygen2 7.3.3)tests/testthat/test-statcast_search.Rmiss_distanceto the expected-columns vectorNEWS.md# baseballr 2.0.0→### Bug fixes(#408)Submission Checklist
CLAUDE.md.devtools::document()and committed the regeneratedman/andNAMESPACE(no hand edits).@param,@return,@export, runnable@examples).devtools::check()passes with no new errors, warnings, or notes.NEWS.md;cran-comments.md/_pkgdown.ymlneed no change (no new export; summary-level cran-comments already covers Savant column handling).Testing
devtools::test()passes locally.Execution time before: N/A
Execution time after: N/A
Screenshots / Output
N/A
Reviewer Checklist
tryCatch; error path returns anempty value with a
climessage rather than erroring.man/andNAMESPACEare regenerated and consistent with the source.NEWS.md/cran-comments.md/_pkgdown.ymlare consistent for anyAPI-surface change.