Lesson 3 of 43
In Progress

Importing Data

Your Turn

You’ll be working with data on Oregon school enrollment by race/ethnicity.

Create a new project. Make sure you put it somewhere you’ll be able to find it again later!

Download the two files using the download.file() function into a data-raw folder (which you’ll need to create).

Create a new R script file where you’ll do all of your data cleaning work

Import the two spreadsheets into two data frames (enrollment_17_18 and enrollment_18_19)

Heads Up!

If you have issues opening the spreadsheet, note that you may need to add the argument mode = "wb" to the download.file() function, as follows (read more about why here). You can see the full code in the solutions section below if necessary.

Learn More

You can read about all of the arguments for the download.file() function here.

To learn more about importing Excel files, check out the readxl package documentation. You’ll see, for example, ways to download only certain ranges of cells, which can be helpful when you have messy Excel data!

I’ve also written an article about cleaning messy data in R. There are many packages to deal with messy data (which often comes in the form of Excel spreadsheets), and I go through several in the post.

Questions about the lesson? Put them below.

Just announced: R in 3 Months, a program to help you FINALLY learn R. Starts March 18.