Importing Excel data using R: Step by Step

Update: Please refer to this blog for various other ways to import excel as the steps outlined by me has dependency on Perl.

In this blog I’m going to share with you the steps involved in importing the data and understanding its aspects from R.


  1. Windows XP
  2. Completed the installation of R (In this example I’m using R version 2.15.2)

Step 1: Keep the Excel ready with you, in this example I’ve prepared my own sample data which is the table which captures of the various employees who have shown interest for stream change. The column labeled “Agreed” captures whether they are agreed or not. Snapshot of the worksheet:

Step 2: I have named the file as datasource.xls

Step 3: For using the Excel we will need the “gdata” package. If we have not installed it we can do it by using the command install.packages(“gdata”). Make sure you have internet connection to download the package.

Step 4: Then issue the command library(gdata), which will enable support for using .xls files in “R”

Step 5: We are going to use the command read.xls. If you need more or additional help regarding the same you can issue help (read.xls) which will start the server and load its relevant content.

Step 6: I have saved the datasource.xls in mydocuments folder

Step 7: Issue the command mydata=read.xls(“datasource.xls”) and again type mydata to see the excel file loaded to the R environment. If the file is missing or there is problem in the path you will get an error.

Step 8: In this final step we can see the summary of data using the command Summary(mydata)


10 thoughts on “Importing Excel data using R: Step by Step

  1. Pingback: Ranking using R: Step by step | My exploration into data analytics

  2. Pingback: SVM Implementation step by step with R: Data Preparation | My exploration into data analytics

  3. It shows for me:

    Error in path.expand(xls) : object ‘sample.xls’ not found
    Error in file.exists(tfn) : invalid ‘file’ argument

    Why? I store in My Document folder as file named sample

  4. Error in findPerl(verbose = verbose) :
    perl executable not found. Use perl= argument to specify the correct path.
    Error in file.exists(tfn) : invalid ‘file’ argument

    what does it means?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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 )


Connecting to %s