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 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
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
Step Six: There and Back again
Importing your files is only one small but essential step in your endeavors with R. From this point, you are ready to start analyzing, manipulating or visualizing the imported data.
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.
← Back to tutorial