Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Passes through to connections::connection_open() when the connections package is installed, making the DuckDB connection visible in RStudio's Connections pane. Gracefully falls back to DBI::dbConnect() otherwise. connections added to Suggests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Rewrite data-raw/salaries.R to use Spotrac AJAX POST endpoint
(POST /mlb/rankings/player/_/year/{year}/sort/cash_total with ajax=table)
Old CSS selectors (.player-name, .rank-position) were obsolete post-2023 redesign
- Parse new div-based table structure: div.link a (name), small (team/pos),
span.medium (salary); yields 1440-1590 players per year with no pagination
- add spotrac_file param to setup_baseball_db(); auto-detects
salaries_spotrac_*_with_playerID.csv in same dir as dbdir
- Load SalariesSpotrac table; add third UNION ALL branch in SalariesAll view
- SalariesAll now covers: Lahman 1985-2016, Spotrac 2017-2021, USA Today 2022+
with no missing years
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Spotrac includes 40-man roster minor leaguers (~500-800/year) at sub-minimum salaries (0K-00K). These are excluded from SalariesAll via a per-year CASE filter to match Lahman's scope (MLB contracts only). MLB minimums used: 2017=$535K, 2018=$545K, 2019=$555K, 2020=$208K (prorated 60-game season), 2021=$570.5K. Result: Spotrac player counts (768-1028/yr) are now consistent with Lahman (802-853) and USA Today (765-938). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add CASE mappings in setup_db.R for Spotrac (CHC→CHN, CHW→CHA, KC→KCA, LAD→LAN, NYM→NYN, NYY→NYA, SD→SDN, SF→SFN, STL→SLN, TB→TBA, WSH→WAS) - Add full team-name→code CASE for USA Today (all 30 franchise name variants) - All SalariesAll teamIDs now join cleanly to the Lahman Teams table Tests added (test-setup.R): - Spotrac team code normalisation (11 remapped codes verified) - Spotrac MLB-minimum salary filter - USA Today team name normalisation (10 name variants verified) - SalariesAll teamIDs have zero unmatched rows against Teams Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Spotrac scraper, MLB minimum filter, team ID normalisation (Spotrac + USA Today to Lahman codes), and SalariesAll covering 1985-2025. Four new tests added; 72 total passing.