R tutorial: How to import data into R

In this book excerpt, learn how to import data into R from spreadsheets, HTML tables, and more

Before you can analyze and visualize data, you have to get that data into R. There are various 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.

The magic of rio

To continue reading this article register now