4 Import Data into R

Before you can analyze and visualize data, you have to get that data into R. There are some different ways to do this, depending on how your data is formatted and where it’s located.

Usually, the function you use to import data depends on the data’s file format. In base R, for example, you can import a CSV file with read.csv(). Hadley Wickham created a package called readxl that, as you might expect, has a function to read in Excel files. There’s another package, googlesheets, for pulling in data from Google spreadsheets.

But if you don’t want to remember all that, there’s rio.