Economics in R

What is this?

"Economics in R" is a book-in-progress intended for young economics graduate students. Much of my time in grad school was spent writing bad code. Time that could have been spent doing more productive things (Like finding another set of null results or figuring out why my model won't converge). This book walks through the basic tools needed to start economics research using the R programming language. This book assumes that you know the methods needed to find results (e.g. difference-in-differences, the RBC model). But you may not know how to implement those methods using statistical software. Disclaimer: I'm still not a professional coder, but hopefully this helps you save a lot of the time that I wasted!


To get young researchers up-and-running as quickly as possible, this book is laid out as follows:

  1. Introduction to R

  2. Basic Data Analysis

  3. Data Visualization

  4. Microeconomic Methods (Incomplete)

  5. Other Resources

A quick note on navigation. This page will now be referenced as the "Table of Contents." There is a button at the top and bottom of each chapter to return here. This is so you can navigate quickly to chapters that are most relevant for you. You can also use the navigation pane on the side bar. If a chapter doesn't apply to you, just skip it. If you're unsure whether to skip a chapter, detailed contents are below.

If you're completely new to R, click the Introduction button below. Otherwise, select the chapter you want to visit from the list above or below.

Detailed Contents

  1. Introduction to R

    • Why R?

    • Downloading R

    • RStudio Interface

    • Data Types and R-Objects

    • Packages

    • Writing Code

    • Using data.tables

    • Saving Files

  2. Basic Data Analysis

    • Data Mining and Cleaning

      1. Data Mining

      2. Data Transformation

      3. Writing Data

    • Data Analysis

      1. Correlations

      2. Regressions

      3. Residuals

  3. Data Visualization

    • Introduction to ggplot

    • Scatterplots

    • Line Graphs (Simple)

    • Line Graphs (Average over Groups)

    • Histograms

  4. Microeconomic Methods (Incomplete)

    • Fixed Effects

    • Instrumental Variables

    • Difference-in-differences

    • Event Studies

  5. Other Resources