recon (short for R + Economics) is an educational project that helps users learn how to use R for economic analysis.
It provides examples, exercises, and best practices for applying data science methods to real-world economic datasets.
This repository is intended for:
- Students and researchers new to R.
- Economists transitioning from tools like Excel, Stata, or Python.
- Anyone who wants a guided introduction to data analysis, visualization, and modeling in R.
You’ll learn how to:
- Work with data frames, tidy data, and use the
tidyverseecosystem. - Apply statistical and econometric methods.
- Create publication-quality visualizations.
- Reproduce and share results in a reproducible way.
Before getting started, make sure you have:
- macOS (other platforms supported with minor modifications)
- Homebrew installed — Installation guide
- R and RStudio (or VS Code with R extension)
If you don’t already have R installed, you can install it easily with Homebrew:
# Update Homebrew
brew update
# Install R
brew install r
# Verify installation
R --versionOptionally, install RStudio for a more user-friendly IDE:
brew install --cask rstudioFor building packages from source on macOS (especially on Apple Silicon), it can help to explicitly set SDK paths and compiler flags.
mkdir -p ~/.Renviron.d
nano ~/.RenvironAdd the following:
# Use the macOS CommandLineTools SDK
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
# Homebrew pkg-config path for dependencies
PKG_CONFIG_PATH=/opt/homebrew/opt/libxml2/lib/pkgconfig:/opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/gettext/lib/pkgconfigSave ('ctrl' + 'O') and close ('ctrl' + 'X')the file.
mkdir -p ~/.R
nano ~/.R/MakevarsAdd the following flags:
# SDK and compiler
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CXX11=/usr/bin/clang++
CXX14=/usr/bin/clang++
CXX17=/usr/bin/clang++
CXX20=/usr/bin/clang++
CFLAGS=-isysroot $(SDKROOT) -O2 -Wall
CXXFLAGS=-isysroot $(SDKROOT) -O2 -Wall
LDFLAGS=-isysroot $(SDKROOT)
# Homebrew libraries
PKG_CONFIG_PATH=/opt/homebrew/opt/libxml2/lib/pkgconfig:/opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/gettext/lib/pkgconfig
CFLAGS += -I/opt/homebrew/include
CPPFLAGS += -I/opt/homebrew/include
CXXFLAGS += -I/opt/homebrew/include
FLIBS=-L/opt/homebrew/opt/gfortran/lib
F77=/opt/homebrew/bin/gfortran
FC=/opt/homebrew/bin/gfortranThis ensures R uses the correct compilers, SDK, and Homebrew-installed libraries when building packages from source.
renv is a dependency management system for R.
It helps ensure everyone working on recon uses the same package versions — critical for reproducibility.
git clone https://github.com/smkacur/recon.git
cd reconFrom within your recon directory, start R and run:
install.packages("renv")
renv::init()This will:
- Create a local renv environment inside the project.
- Snapshot installed packages to renv.lock.
If you’ve just cloned the repo and a lockfile already exists:
install.packages("renv")
renv::restore()This ensures all required packages are installed in your isolated environment.
To use R within VS Code, follow these steps:
- Open VS Code
- Go to Extensions (⇧⌘X on macOS)
- Search for R and install the extension by Yuki Ueda (or similar)
- Press Cmd+, to open Settings
- Search for R: Rterm Path
- Set the path to your Homebrew R binary, e.g.:
/opt/homebrew/bin/R- Start R in your terminal or VS Code console:
renv::install("languageserver")This provides code completion, diagnostics, and linting.
- Ensure that your PATH includes Homebrew and your compilers (/opt/homebrew/bin) so that packages can build correctly.
After this setup, you can run R scripts, use the interactive terminal, and benefit from code completions and diagnostics directly in VS Code.
Make sure you have R installed (you already have it via Homebrew).
Open R (in terminal or VS Code) and install the IRkernel package:
renv::install("IRkernel")
IRkernel::installspec(user = TRUE)IRkernel allows Jupyter to recognize R as a kernel. user = TRUE installs the kernel only for your user account.
If you don’t already have Jupyter:
# Using pip in your terminal
pip install notebook jupyterlabContributions are welcome! If you’d like to add lessons, datasets, or exercises: