1
Introduction
1.1
Who this guide is for
1.2
What this guide will teach you
1.3
What this guide won’t teach you (and some external resources to help with that)
1.4
Outline
1.5
Acknowledgements
2
Setup
2.1
Downloading R
2.1.1
For Windows users
2.1.2
For Mac users
2.2
Downloading RStudio
2.2.1
For Mac users
2.2.2
For Windows users
2.3
Common installation issues
2.4
A tour of RStudio
2.4.1
The console pane
2.4.2
The environment pane
2.4.3
The plots pane
2.4.4
The source pane
3
The Basics
3.1
How coding works
3.2
R objects
3.2.1
Scalars and numeric vectors
3.2.2
Logical vectors
3.2.3
Character vectors
3.2.4
Converting between data types
3.3
Packages
3.4
Aside: indentation and line endings
3.5
Data frames
3.5.1
Creating new dataframes
3.5.2
Manipulating dataframes
3.5.3
Doing it in
dplyr
3.6
Debugging tips
4
Plotting
4.1
ggplot concepts
4.2
Examples
4.2.1
Histogram
4.2.2
Scatter plots
4.2.3
Line plots
4.2.4
Bar Plots
4.2.5
Some theme options
4.3
Special functions for binned scatter plots
4.3.1
Binsreg
4.3.2
Regression discontinuity plots
4.4
Maps
5
Cleaning data
5.1
Loading data
5.1.1
The working directory
5.1.2
Reading csv files
5.2
Variable selection and subsetting
5.3
Merging datasets
5.4
Pausing to look at the data
5.4.1
Dealing with outliers and missing values
5.5
Summarizing and grouped operations
5.5.1
summarize()
5.5.2
Pivoting
5.5.3
Grouped summarize
5.6
Common variable manipulations
5.6.1
Indicator variables
5.6.2
Factors
5.6.3
Group averages
5.6.4
Cumulative sums
6
Regression
6.1
Fixest syntax
6.1.1
Accessing estimates
6.1.2
Fixed effects
6.1.3
Alternative standard errors
6.1.4
Weights
6.2
Making tables with
etable
6.2.1
Formatting
6.3
Instrumental variables
6.4
Event Studies
7
Sample Script
7.1
Script Hygiene
7.2
Saving output
7.3
A simple recipe for a good R script
7.4
A sample R script
8
Organizing Larger Projects
9
Advanced Topics
10
Markdown
R for Applied Economics: A Beginner’s Guide
10
Markdown
TODO