Lab 01 - Hello R!

Due: Wednesday 2020-01-22 at 5pm


R is the name of the programming language itself and RStudio is a convenient interface.

The main goal of this lab is to introduce you to R and RStudio, which we will be using throughout the course both to learn the statistical concepts discussed in the course and to analyze real data and come to informed conclusions.

git is a version control system (like “Track Changes” features from Microsoft Word on steroids) and GitHub is the home for your Git-based projects on the internet (like DropBox but much, much better).

An additional goal is to introduce you to git and GitHub, which is the collaboration and version control system that we will be using throughout the course.

As the labs progress, you are encouraged to explore beyond what the labs dictate; a willingness to experiment will make you a much better programmer. Before we get to that stage, however, you need to build some basic fluency in R. Today we begin with the fundamental building blocks of R and RStudio: the interface, reading in data, and basic commands.

Getting started

Each of your assignments will begin with the following steps. You saw these once in class, they’re outlined in detail here again. Going forward each lab will start with a “Getting started” section but details will be a bit more sparse than this. You can always refer back to this lab for a detailed list of the steps involved for getting started with an assignment.

The following screencast also walks you through these steps:


In this lab we will work with two packages: ISLR which is a package that accomponies your textbook and tidyverse which is a collection of packages for doing data analysis in a “tidy” way.

Install these packages by running the following in the console.


Now that the necessary packages are installed, you should be able to Knit your document and see the results.

If you’d like to run your code in the Console as well you’ll also need to load the packages there. To do so, run the following in the console.


Note that the packages are also loaded with the same commands in your R Markdown document.


Your email address is the address tied to your GitHub account and your name should be first and last name.

Before we can get started we need to take care of some required housekeeping. Specifically, we need to configure your git so that RStudio can communicate with GitHub. This requires two pieces of information: your email address and your name.

The following screencast is a demo of what you need to do to configure your git.

To do so, follow these steps:

git config --global "your email"
git config --global "your name"

For example, for me these are

git config --global ""
git config --global "Lucy D'Agostino McGowan"

To confirm that the changes have been implemented, run the following

git config --global
git config --global

Warm up

Before we introduce the data, let’s warm up with some simple exercises. The following video is an overview of some of these warmup exercises.

Project name:

Currently your project is called Untitled Project. Update the name of your project to be “Lab 01 - Hello R”.

The top portion of your R Markdown file (between the three dashed lines) is called YAML. It stands for “YAML Ain’t Markup Language”. It is a human friendly data serialization standard for all programming languages. All you need to know is that this area is called the YAML (we will refer to it as such) and that it contains meta information about your document.


Open the R Markdown (Rmd) file in your project, change the author name to your name, and knit the document.

Commiting changes:

Then Go to the Git pane in your RStudio.

If you have made changes to your Rmd file, you should see it listed here. Click on it to select it in this list and then click on Diff. This shows you the difference between the last committed state of the document and its current state that includes your changes. If you’re happy with these changes, write “Update author name” in the Commit message box and hit Commit.