How to open excel files using R!

There are many ways to  open an excel file. The problem is that based on the operating system that you are working on you might face some problems using a particular method. For example, XLconnect depends on Java to run. So if your laptop/PC does not have Java installed XLconnect will not work. In this post I will try to present most of theavailable packages.


XLconnect package

Cran link

Rdocumentation

SystemRequirements: Java (>= 6)

Opens both .xls and .xlsx files. Most people prefer this package because it allows you to also create excel files or amend them.

Example:

path <- "c:myfolder/myexcel.xls"  
 wb = loadWorkbook(path)   

Openxlsx

CRAN link

Rdocumentation

Opens both .xls and .xlsx files.

Example:

 data <- read.xlsx("myexcel.xlsx", sheet = 1, detectDates = TRUE)  


Gdata

CRAN

Rdocumentation

SystemRequirements: perl (>= 5.10.0)

Example:

 data <- read.xls("myexcel.xls",sheet = 1)  

Readxl

CRAN

Rdocumentation

Tidyverse

*IF you are already using tidyverse most probably it is already inside that package

 data <- readxl_example("myexcel.xlsx")  

Xlsx

CRAN

Rdocumentation

Example:

  file <- system.file("myexcel", "myexcel.xlsx", package = "xlsx")  
  data <- read.xlsx(file, 1)   

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s