Excel File in R

The excel file extension that stores data in the .xls or xlsx format. There are several packages to perform the operations on an excel file in R programming. These packages are XLConnect, xlsx, gdata etc.

Install xlsx Package

You can use the following command in the R console to install the “xlsx” package.

Verify and Load the “xlsx” Package

Use the following command to verify and load the “xlsx” package.

Input the Excel File

To input as xlsx file copy the following data and paste it in the worksheet named sheet1.

Reading the Excel File in R

Below is the input xlsx read by using the read.xlsx() function. The result is stored as a data frame in the R.

Output:

Excel File in R

Writing data into Excel File in R

You can also write the data into .xlsx file in R programming. The write.xlsx() function is used to write data into the excel file.

Below is the creating of the write.xlsx() function: