For Gov 50, you will need to install some free and safe software. This document will walk you through installing the tools we will be using in this course.
First, we will install a programming language called R
. This is the tool we will be using throughout the course to analyze data and make plots.
R is a programming language that will help you do useful things with data. R looks like this - although it looks like nonsense to you right now, this will make sense very soon! You can try to read through this code below to get a sense of what it might be doing (I’ll put the answer at the very end of this document).
<- subset(pop_by_year, country == "New Zealand")
nz mean(nz$population)
To install R, go to this link: https://cran.r-project.org/
On this website, go to the section in the red box below and click on the type of your computer (probably either Windows or Mac).
Figure 1: Choose Mac or PC depending on what kind of computer you have.
If you have a Mac, click on the first .pkg
link (in the red box below). This will download a file. Open it and follow the instructions to install it like you would any other program.
Figure 2: If you have a Mac, this screen will look like this.
If you have a Windows computer, first click on base and then Download R 4.1.0 for Windows (in the red boxes below).
Figure 3: If you have a Windows PC, this screen will look like this.
Then, click on the files you downloaded and follow the instructional prompts to install.
Once that is done, now we need to install a program called RStudio. This is an application that will allow you to interact with the programming language R. Although you can use R without it, RStudio is useful because it will let you see your code, data, plots, and everything else all in one place (and many other reasons that will become clear over the course of the semester!).
Figure 4: RStudio will help put your data, code, and plots all in one place.
To install RStudio, go to this link: https://www.rstudio.com/products/rstudio/
Once there, follow the picture below to:
Click on the downloaded file and follow the instructions to install RStudio.
Figure 5: Follow this process to download RStudio.
Gov 50 will also use Slack for course communications. You will use Slack throughout the semester for course announcements, asking questions, and troubleshooting. One nice part about Slack is that you can see what others post, so if someone asks a question everyone can benefit. If you need, you can also direct message course staff to ask private questions. I will share a link with you to sign-up for the course Slack. If you’ve never used Slack before, the link will ask you to download the program and create an account with your Harvard email.
Figure 6: Welcome to Slack.
When you open the RStudio program for the first time, it will look something like this:
Figure 7: RStudio: Your new best friend for the semester!
There are different sections of RStudio, as described below and shown in the picture:
Let’s try to evaluate some code. In the >
part of the console, try typing in 2 + 7
like this and press Enter (or return depending on your computer):
Awesome! If that code evaluated to 9
, your installation is working. The console is only a temporary place for code. We’ll soon talk about ways to save and store your code.
R has many free add-ons that you can use to access new tools. These are called packages
, and they give you access to code that other people have written to make your life easier.
We’ll install some packages that you are going to use for this course to turn in assignments. Paste each line of the code below individually into the console and press Enter. This might take a minute to run, but you will only need to do it once. If you see any errors or bugs, please let someone know and we will help:
install.packages("devtools")
::install_github("kosukeimai/qss-package", build_vignettes = TRUE)
remotes::install_github("rstudio/learnr")
remotes::install_github("rstudio-education/gradethis")
remotes::install_github("mattblackwell/qsslearnr") remotes
This should create a new tab called “Tutorial” in the pane with Environment, History, and Connections.
Choose one of the tutorials on the list and click “Start Tutorial” to open a new window:
If you don’t see a Tutorial Tab, you can also open tutorial with code, like this:
::run_tutorial("00-intro", package = "qsslearnr") learnr
If you either see the Tutorial tab or the code above opens a window with a tutorial, then you are all set and ready to go.
Congratulations! You’ve installed all of the necessary materials for this course.
Slack uses a series of “channels,” basically different places to have discussions. You can also message members of the course staff directly, though in general most questions should be asked publicly so other students can benefit.
One nice reason to use Slack is that you can use it to share code! You can type regular text in the message box (and use formatting tools like bold and lists), but if you click on the “code block” button you can also paste code in directly:
::include_graphics("../figs/l0_code_slack.png") knitr