1 An Introduction to Analytics

1.3 Working with Data: An Introduction to R

Introduction to R

The slides for this sequence can be downloaded here: Introduction to the R Programming Language (PDF).

Before beginning this lecture, please download and install R for free from the following webpage: The R Project.

At the top of the page, select your operating system (Linux, Windows, or Mac) and then follow the instructions. 

For most Windows users, you will select “install R for the first time” and then select “Download R 3.2.0 for Windows” at the top of the page. 

For Mac users, you will want to download R-3.2.0.pkg if you have OS X 10.9 (mavericks) or higher installed and R-3.1.3-snowleopard.pkg for earlier versions of the operating system.  Please note that either version of R will work for this course.

Once you have downloaded and installed R, please start the application, and then answer the following quick questions. This is to make sure that you have correctly installed R.

 

Quick Questions for Installing R

When you start R, you should see a window titled “R Console”. In this window, there is some text, and then at the bottom there should be a > symbol (greater than symbol), followed by a blinking cursor. At the cursor, type:

sd(c(5,8,12))

and then hit enter. You should see [1] followed by a number. What is this number?

Exercise 1

 Numerical Response 

 

Now type:

which.min(c(4,1,6))

at the cursor, and hit enter. You should again see [1], followed by a number. What is this number?

Exercise 2

 Numerical Response 

 

If you correctly answered both of these questions in R, you are ready to start the lecture! If not, please go to the discussion forum to get help installing R.

CheckShow Answer

Important Note

If you downloaded and installed R in a location other than the United States, you might encounter some formatting issues later in this class due to language differences. To fix this, you will need to type in your R console:

Sys.setlocale(“LC_ALL”, “C”)

This will only change the locale for your current R session, so please make a note to run this command when you are working on any lectures or exercises that might depend on the English language (for example, the names for the days of the week).

Course Info

Learning Resource Types

theaters Lecture Videos
notes Lecture Notes
assignment_turned_in Problem Sets with Solutions