$ show nmaggiulli/of-dollars-and-data
This repository powers the personal finance blog 'OfDollarsAndData.com'. It is primarily a data research collection, consisting of hundreds of R scripts that import, clean, and analyze financial and economic datasets to produce publication-ready charts, tables, and interactive calculators for blog posts. The data lineage is clear: raw data is downloaded or read from external sources (Shiller S&P 500, FRED, BLS, Survey of Consumer Finances, YCharts, etc.) in import/ scripts, transformed and saved as RDS files in build/ scripts, and then consumed by analysis/ scripts that generate plots with a consistent ggplot theme. The repository also includes a webdev folder containing a WordPress theme with custom widgets and calculator embedding logic. While the codebase is not a packaged application and lacks testing or CI, the analysis is thorough and well-structured for its purpose. The hybrid nature includes both data research R scripts and web development PHP/JS code, but the dominant character is data research.
The LLM identified 3 files worth highlighting for reuse:
Contains a collection of reusable R helper functions such as `drawdown_path()` for computing drawdown series, `export_to_excel()` for writing styled Excel files, `create_gif()` for animating plot sequences, `date_to_string()` for consistent date formatting, and `format_as_dollar()`. These functions are sourced by every analysis script via `header.R` and could be extracted into a standalone R package for any project needing financial charting and export utilities.
Central configuration script sourced by all analysis scripts. Defines project file paths (`localdir`, `exportdir`, `importdir`), loads common libraries, sets a custom ggplot2 theme (`of_dollars_and_data_theme`), and sources `custom_functions.R`. This pattern of a single header file for path setup, theme definition, and library loading is a good practice for reproducible R projects and can be adapted to other data analysis workflows.
Implements a mean-variance efficient frontier using quadratic programming (`solve.QP`). The `eff_frontier()` function takes return data and computes the optimal portfolios across a range of target returns. Though specific to Bitcoin and gold, the core optimization logic is generic and can be reused for any multi-asset portfolio analysis. The function is self-contained and demonstrates a solid understanding of portfolio theory and numerical optimization in R.