Notes made in preparation for a readxl RStudio webinar given on 2017-05-10. A recording can be found at that link. Slides can be found on SpeakerDeck. Slides and more can be found in the RStudio Webinar GitHub repo or in readxl's GitHub repo.
Like it or not, spreadsheets are a common data source for many of us. We’ll review the overall landscape for importing spreadsheet data into R and then go into detail for the readxl package specifically. readxl is the Tidyverse solution for reading data stored in the legacy xls format or the more modern xlsx format. It has no tricky external dependencies, is quite speedy, and is easy to install and use across all operating systems.
readxl is the Excel-reading package with an interface that is most consistent with, e.g., readr, haven, etc. in terms of data import. Why does this matter?
Key concept: once you get data into R, it's stored as a tibble, which is a special flavor of data frame.
There are many R packages that can read Excel spreadsheets besides readxl, such as:
Why would you pick readxl?
.xls
and .xlsx
(see next section).xls
= legacy Excel format, Excel '97(-2007)
.xlsx
= modern Excel format
Pick a package that reads the format(s) you have.
All Excel-reading R packages are relying on external libraries. The only question is whether the user will feel that or not.
readxl benefits from
readxl fully embeds these libraries. On Mac, Windows, and Linux, you should be able to just install readxl and go.
The alternative: get the user to install external dependencies.
gdata
.readxl targets rectangular data in spreadsheets.
Draw on these resources:
Access the RStudio helper in one of two ways:
.xls
or .xlsx
> Import Dataset...What's cool about it?
read_excel()
, such as:skip
, n_max
, or range
.xls
and .xlsx
from a URL than readxl does at the momentBear in mind there are more arguments to read_excel()
and more flexible ways to use these arguments if you write the code yourself.
Draw on these resources:
Draw on http://readxl.tidyverse.org/articles/articles/readxl-workflows.html
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.