Read an Excel file directly from a R script

waanders picture waanders · May 23, 2011 · Viewed 191.5k times · Source

How can I read an Excel file directly into R? Or should I first export the data to a text- or CSV file and import that file into R?

Answer

JD Long picture JD Long · May 23, 2011

Let me reiterate what @Chase recommended: Use XLConnect.

The reasons for using XLConnect are, in my opinion:

  1. Cross platform. XLConnect is written in Java and, thus, will run on Win, Linux, Mac with no change of your R code (except possibly path strings)
  2. Nothing else to load. Just install XLConnect and get on with life.
  3. You only mentioned reading Excel files, but XLConnect will also write Excel files, including changing cell formatting. And it will do this from Linux or Mac, not just Win.

XLConnect is somewhat new compared to other solutions so it is less frequently mentioned in blog posts and reference docs. For me it's been very useful.