Start Learning for Free

Join over 500,000 other Data Science learners and start one of our interactive tutorials today!

Topic r small

Reading and Importing Excel Files into R

April 3rd, 2015 in R Programming

What’s Excel’s Connection To R?

As most of you know, Excel is a spreadsheet application developed by Microsoft. It is an easily accessible tool for organizing, analyzing and storing data in tables and has a widespread use in many different application fields all over the world. It doesn't need to surprise that R has implemented some ways to read, write and manipulate Excel files (and spreadsheets in general).

This tutorial on reading and importing Excel files into R will give an overview of some of the options that exist to import Excel files and spreadsheets of different extensions to R. Both basic commands in R and dedicated packages are covered. At the same time, some of the most common problems that you can face when loading Excel files and spreadsheets into R will be addressed.

Want to dive deeper? Check out this DataCamp course on importing data with R, which has a chapter on importing Excel data.


Step Five. Final Checkup

After executing the command to read in the file in which your data set is stored, you might want to check one last time to see if you imported the file correctly.

Remember to type in the following command to check the attributes’ data types of your data set:

str("<name of the variable in which you stored your data>")

Alternatively, you can also type in:

head("<name of the variable in which you stored your data>")

By executing this command, you will get to see the first rows of your data frame. This will allow you to check if the data set’s fields were correctly separated, if you didn’t forget to specify or indicate the header, etc.

Note that you can add an argument n to head() to specify the number of data frame rows you want to return, like in: head(df, 5) to return the first five lines of the data frame df.

Step Six. There And Back Again

Importing your files is only one small but essential step in your endeavours with R. From this point, you are ready to start analyzing, manipulating or visualizing the imported data.

Do you want to continue already and get started with the data of your newly imported Excel file? Check out our tuturials for beginners on histograms and machine learning.

This tutorial was written in collaboration with Jens Leerssen, Data Quality Analyst with a passion for resolving data quality issues at scale in large, documentation sparse environments.


How to read the data from the second, third,.... sheets of a .csv file?
02/11/16 9:09 AM |
.csv files are plain text and can&#39;t have sheets, which are a feature of Excel files.
08/16/16 7:49 PM |