Readr
Summary

Instruction

In this section, we're going to explore the tidyverse package readr. Readr allows us to import "rectangular data" – in other words, data stored in formats like CSV (comma-separated values), TSV (tab-separated values), and FWF (fixed-width format).

To understand how to work with readr, let's imagine we're working for a city department that receives reports from various other departments. This data is coming from several different locations and in different formats. And it almost certainly contains some errors.

How can we keep the chaos under control? We will learn how to manage those errors, and we'll leave out different reading functions, such as read_tsv() or read_fwf() – they work the same way as read_csv().

We need to use something that will read all the reports and keep them in R: the readr package.

Exercise

From our previous sections, we already know how to use the read_csv() function to access the data in CSV files. Data about the students at Winters University is in data/winters_students.csv. Use read_csv() to access this data and assign it to the students variable.

Stuck? Here's a hint!

Type:

students <- read_csv("data/winters_students.csv")