Reading in Excel data with the readxl R package

The readxl R package makes it very easy and straightforward to read data from Excel files into R:

We start by loading the module into R:

library(readxl)

Reading Excel data with readxl is simple; we just need to call the read_excel function and pass in the file path, as follows:

read_excel("data.xls")

readxl supports both the old XLS and the new XLSX format. It guesses the format from the extension of the file being read:

read_excel("data.xlsx")

Excel files sometimes have multiple sheets. For example, the following Excel file has multiple sheets:

You can easily handle them with the readxl package. ...

Get Hands-On Exploratory Data Analysis with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.