How to Read and Write an Excel File in R?

Description

To Read and Write an Excel File using R programming.

  • R Package :xlsx
  • R Package : openxlsx — for big excel file.
  • R Function to read : xlsx()
  • R Function to write : xlsx()

#Reading Excel File

#Get and Set Working Directory
print(getwd())
setwd(“/home/soft13″)
getwd()

#Read file from Excel
#install.packages(“xlsx”)
library(“xlsx”)
dataSet<-read.xlsx(“ExcelReadData.xlsx”,sheetIndex=1)
print(dataSet)
View(dataSet)

#Write data into an Excel File
readData<-read.xlsx(“ExcelWriteData.xlsx”,sheetIndex=1)
write.xlsx(readData,”ExcelOutput.xlsx”,append=FALSE)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit