R Data Interfaces Excel File - R Programming language

What is R Excel file?

As we know that Microsoft Excel is the popular spreadsheet program which stores data in the .xls or .xlsx format. R allows to read directly from these files using some excel specific packages like XLConnect, xlsx, gdata etc. Here we use xlsx package.

How to install xlsx Package?

To install Xlsx package you need use the below command in the R console. Based on the package you select it will ask to install some additional packages. Follow the same command with required package name to install the additional packages.

How to verify and Load the "xlsx" Package?

Below mentioned command is useful to verify and load the "xlsx" package.
When the script is run we get the following output.

Input as xlsx File

To input as xlsx file you need to open Microsoft excel, then copy and paste the following data in the work sheet named as sheet1.
Also copy and paste the following data to another worksheet and rename this worksheet to "city".
Now, save the Excel file as "input.xlsx" in the current working directory of the R workspace.

Reading the Excel File

The input.xlsx is read by using the read.xlsx() function as shown below. The result is stored as a data frame in the R environment.
Here’s final output produced when we execute the above code.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

R Programming language Topics