$ show FantasyFootballAnalytics/FantasyFootballAnalyticsR
This repository is a comprehensive fantasy football analytics platform built in R. It ingests player projections from over a dozen sources (CBS, ESPN, Yahoo, FantasyPros, etc.) via web scraping, transforms them into consensus estimates using robust statistics (Hodges-Lehmann estimator, weighted averages), and produces actionable insights such as player risk scores, value over replacement (VOR), optimal roster selections via linear programming, and draft-day bid-up-to recommendations. The pipeline also includes historical analysis modules that evaluate projection accuracy against actual Yahoo fantasy points, model expected values, and identify undervalued players ('gold mining'). The codebase is organized as a collection of R scripts with a clear separation of concerns: configuration (league settings, source definitions), reusable functions (data melting, value redistribution, scraping helpers), source-specific projection scrapers, calculation modules (risk, VOR, simulation, optimization), and post-processing for draft day and weekly roundups. Data is stored in both CSV and RData formats, with historical archives spanning 2008-2015. While the repository demonstrates solid data engineering patternsβexternalized configuration, modular functions, robust statistical methods, and optimizationβit suffers from significant maintenance and reproducibility issues. The scraping code is brittle, relying on hardcoded HTML structures that are likely broken. Dependencies are not pinned, and many packages (e.g., Rglpk, reshape, psych) may be unavailable or incompatible with modern R versions. The data is largely from 2013-2015, making it obsolete for current NFL analysis. There are no tests, and manual steps are required for some data acquisition. As a result, the repository is best treated as a historical reference and a source of reusable patterns rather than a production-ready system.
The LLM identified 5 files worth highlighting for reuse:
Provides reusable utility functions for fantasy football analytics, including name merging, MASE calculation, weighted standard deviation, Wilcoxon location estimator, defensive points calculation, and team abbreviation conversion. These functions are isolated and can be extracted for any fantasy football analysis project.
Implements a configurable scraping framework with site-specific getters, error handling via tryCatch, and consistent data extraction. The pattern of externalizing site configurations (URLs, column mappings) into CSV files makes it adaptable to new sources and improves maintainability.
Uses Rglpk to solve a constrained optimization problem for selecting the optimal fantasy football roster under budget and risk constraints. The formulation is clear and could be adapted to other selection problems, demonstrating a reusable optimization pattern.
Computes weighted average and Hodges-Lehmann estimator for combining projections from multiple sources, with options for weighting by source reliability. This robust aggregation pattern is reusable for any multi-source estimation task.
Externalizes site URLs, table indices, and column mappings into a CSV file, enabling easy addition or modification of data sources without changing code. This pattern improves maintainability and reusability of the scraping pipeline.