Data and Other Resources

Look here over the course of the semester for resources, links, and tips on how to succeed in the course. For weekly data exercises, see the sidebar. Assignments are linked in the sidebar and on the Deliverables page.

R Markdown for Econ 366

You should be able to do anything you need to do for this class in R Markdown. The coding will all be in code chunks that will make it easy for me and others to see how you’ve done the work, and will teach you to write self-contained code. This document has an option enabled called code-folding which lets you hide the code behind tabs for easier reading.

Installing R and R Studio

The first thing you’ll want to do, if you haven’t done so already, is to install R and the editor RStudio. Once you have those installed, you’re ready to create a basic R Markdown document. This document from Earth Lab provides a great introduction, on which I’ll base some of what follows here on their introduction. You can also watch this video. If you can create a new RMarkdown document and render (knit) it, you’re well on your way.

R Packages

Base R has a lot of functionality, but one of the strengths (and challenges) of R is that it relies on packages which make lots of very powerful data work possible, but also mean that two people can attack a problem in R in very different ways. When I look back at some of my old R code, it’s almost incomprehensible because I used to use a very different set of packages than I use today. For most of the work in this class, we’ll rely on the tidyverse so you can install that package to get going. You can check with packages you have installed in this window:

If you don’t have the tidyverse package installed, install it now. I would also recommend that you also install a package called janitor for the purpose of data cleaning. We’ll add more packages to our list over the course of the term.

An initial data demo is here and, for your reference, an RMarkdown file that generates all of this content is here.

R Markdown vs Scripting vs R Console

A few of you have talked to me about running R code in different ways, and some are confused by the difference between an R script and an R-Markdown document. Hopefully this example will help - you can access it as a standalone document here.

Filtering

A few of you seem to be struggling with filtering data. I put up a little tutorial on filtering for you here with a little bonus at the end.

Functions

Functions are a really powerful part of any programming language, since they let you partially-automate repeated tasks like downloading data, making graphs, and the like. I have added a short tutorial on functions for you here using some data from the second assignment, and with a little bonus at the end.