Use R with Excel: Importing and Exporting Data

  1. Data Management

Tags

  • Databases
  • Import Data
  • R Programming
  • Tips & Tricks

In this article, you learn how to connect R with Excel by importing and exporting data between the two programs.

Excel: pros and cons

Excel is still very popular among companies and organizations. One of the main advantages in a spreadsheet is ease of providing the user with a rapid overview of a dataset, using visualizations and tables. On the other hand, given the incredible growth of data, the spreadsheet really lacks efficient and agile solutions for data management and data cleaning.

Solution: Use R with Excel

Fortunately, it is possible for the data scientist/analyst to empower the advantages of both Excel and R. This can be done with some value adding and efficient packages for R. What Excel lack in data management and data cleaning – R is an excellent and efficient solution for these tasks. Furthermore, it is also possible to create the analytics in R and export the result into Excel for reporting. Basically, you have two great solutions (1): You can import Excel datasets into R for data management, data cleaning and analytics (2): You can export analytical results and clean data from R into Excel for further analytics or presentation.

The below sections presents these solutions with coding examples in R. First we look at how you import Excel into R:

Import Excel spread sheet in R

Now let us use the above import coding with an Excel sheet. We use this demand data:

Import Excel spread sheet in R with a dataset

The above coding gives us the following table

Export Excel spread sheet in R

Now it is time to Export Excel sheet from R into Excel:

Export spread sheet from R to Excel

Let us use the above export coding with the demand excel sheet. First we do some data management in R:

Export spread sheet from R to Excel with a dataset

The above coding gives us the following table

Happy coding!

References

  1. Using readxl in R – CRAN.R-project.org

  2. Using xlsx in R – CRAN.R-project.org


Related Post

  • Combining data in R: the skill of merging, joining, and stacking
  • Efficient data management and SQL data selection in R
  • Essential data cleaning for ad-hoc tasks in R
  • Proteomics Data Analysis (2/3): Data Filtering and Missing Value Imputation
  • Clean Your Data in Seconds with This R Function

Related