Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
13. Exercise 1


It's time to recap what we learned about readr.

We learned how to read data from a CSV format to R using read_csv(). We also learned how to handle some errors by skipping lines (using the skip argument) and to handle missing column names (using the col_names argument):

read_csv("data/winters_students.csv", skip = 5, col_names = FALSE)

We can check the column data types of the dataset with the spec() function:


We can investigate problems encountered when reading the file with the problems() function:


We can read general files into R using any kind of delimiting character, thanks to the read_delim() function:

read_delim("data/zoo.csv", delim = "|")

And we can save data in different formats using the write_delim() function:

write_delim(animals, path = "animals.csv", delim = ";")

Let's practice all the know-how we just acquired. Our final report comes from the Hillside Clinic. Let's see what's in it.


We have data from the Hillsdale Clinic about patients and the treatments they received. Read data/hospital.csv into the patients variable using read_csv().

Stuck? Here's a hint!


patients <- read_csv("data/hospital.csv")