Department of Applied Economics
University of Minnesota
Summer 2025
This one-week course is a boot camp designed to introduce you to R statistical software. My goal is to build a strong foundation for your Ph.D.-level econometrics courses and future research.
By the end of this week, you will be able to:
to create and manipulate the base-R object data.
to do data manipulation with data.table
package.
to do data visualization with ggplot2
package.
to conduct regression analysis with lm()
and make a publish-ready regression table with modelsummary()
package.
to write Monte code for Carlo simulations using for loop
function.
We will meet each day from 1:00 PM to 4:00 PM, with office hours immediately following.
Each lecture is divided into three sessions, with each session consisting of a 50-minute lecture and a 10-minute break.
We will have in-class exercises at the end of each topic, and after-class exercises (optional) to practice!
No textbook is required. Below are recommended resources:
Recommended Reading
Essential Cheatsheets
Comparison of R, Stata, and Python
Criteria | R | Stata | Python |
---|---|---|---|
Primary Use | Statistical analysis, visualization, research | Economics/social science research; valued for tested results | General-purpose; machine learning, web scraping, automation |
Cost | Open-source | Commercial license | Open-source |
Data Visualization | Excellent | Less flexible or aesthetically pleasing | Very powerful, but can be verbose |
Ecosystem | Large academic community; many packages on CRAN | Strong in economics but smaller user base | Huge, diverse community |
Handling Big Data | Base R is memory-bound; packages like data.table / arrow improve performance |
Memory-bound | Excellent |
You can use app to write and run R codes, but it has a terrible graphic user interface.
Rstudio is an Integrated Development Environment. It provides a user-friendly interface to write and run R code, view plots, and manage files.
You must install R (the engine) before you can use RStudio!
R studio looks like this:
To create new R script file, click the +
button on the top-left corner of the Rstudio, or hit Ctrl
+ Shift
+ N
(Cmd
+ Shift
+ N
on mac).
To save the file, click the floppy disk icon , or Ctrl
+ S
(Cmd
+ S
on macOS).
Tools
-> Global Options
-> Appearance
-> Editor theme
and select your favorite theme.Tools
-> Global Options
-> Pane Layout
-> Add Column
.Recent R-studio has a new feature called “Command Palette.”
Hit Ctrl
+ Shift
+ P
(Cmd
+ Shift
+ P
on macOS) on your keyboard, or go to Tools
-> Show Command Palette
.
From here, you can search for and do almost anything: create new files, open projects, etc.
Let’s write some codes.
R code
Ctrl
+ Enter
(Cmd
+ Enter
on macOS).Comment block
#
is a comment. R will ignore it. Use comments to leave notes for yourself and others!You are now familiar with the basics of RStudio. As long as you know how to create, save, and run a script, you are ready for the next lecture.
For more details, see the official RStudio IDE Cheatsheet.
While RStudio is the most popular tool, you can also run R in other editors like Visual Studio Code to run R. Nevertheless, Rstudio is a great starting point to get familiar with R.