Political Analysis in R

The website for the course.

Joe Ornstein https://joeornstein.github.io/ (University of Georgia)https://spia.uga.edu/departments-centers/department-of-political-science/

Overview

In this course, you’ll learn how to work with data using the R programming language.1 By the end of the semester, you’ll be able to:

All the course materials you need will be available on this website. Check the Schedule tab for an overview of each week’s topics and assignments. On the navbar, you can also find links to read the syllabus, schedule an office hours appointment, and visit the class code repository.

Getting Started

There is a lot of software to install for this class, but in the instructions below I’ve tried to make it as straightforward as possible. (And everything is free!) Before the end of our first week, please complete the following steps.

The Programming Language (R)

You won’t get super far in an R class without R. The most current version is available here. To download, click link for your operating system (i.e. Mac, Windows, Linux), then follow the instructions on the page.

The Interface (RStudio)

R is the programming language itself, but it comes with a pretty unfriendly interface.

You don’t want to do all your typing in that lonely black box. Instead, you want RStudio, a piece of software that makes R much prettier. Download the RStudio Desktop version here.

OPTIONAL: Version Control (git)

Professional coders use a version control system called git to keep track of their code. If you’re on a Mac, skip this section. Your machine already has it installed.2 If you use a PC, follow the installation instructions here.

Once git is installed, it will want you to introduce yourself. To do so, follow these three steps:

1. In RStudio, click `Tools > Shell`. This will open your computer’s shell, a program that runs other programs.

2. Type and enter git config --global user.name 'Jane Doe' (substituting your name for Jane Doe).

3. Type and enter git config --global user.email 'jane@example.com' (substituting your email for that fake email address).

Using git to track changes in your code involves a bit of struggle on the front end, but it is well worth it (Bryan 2017).3 I’ll walk you through the basics in class.

OPTIONAL: Memory Aid (Anki)

A lot of learning to write code is memorizing the names of functions and what they do. This is the boring and frustrating part, but there are ways to make it somewhat less boring and frustrating. Do yourself a favor and take 20 minutes and play through Case (2018). If you’re convinced, download Anki. It’s not the prettiest spaced repetition software out there, but it is free, streamlined, highly customizable, and has a large, dedicated fanbase.

OPTIONAL: Reference Management (Zotero)

You won’t need Zotero to complete any of the assignments in this class, but I like to evangelize it whenever I can. This software makes it blindingly simple to keep track of and format your citations. It also plays really nicely with RStudio. Download it here and follow the setup instructions. The Chrome extension is particularly useful; anything you find on the Internet can be saved to your library with one click.

Bryan, Jennifer. 2017. “Excuse Me, Do You Have a Moment to Talk about Version Control?” https://doi.org/10.7287/peerj.preprints.3159v2.
Case, Nicky. 2018. “How To Remember Anything Forever-Ish.” https://ncase.me/remember/.

  1. R is a powerful (and in-demand!) tool for data analysis and communication. For example, this very website was built with R.↩︎

  2. I think? If you’re on a Mac and you can’t get git to work, let me know!↩︎

  3. It’s something you can put on your resume and people will be super impressed.↩︎

References