How to export an Excel file (sheet) in R

The package openxlsx allows an easy deletion of existing Excel files and sheets.

library(openxlsx)

write.xlsx(x, "temp.xlsx", sheetName="merged data",
col.names=TRUE, row.names=TRUE, append=TRUE,overwrite=TRUE)

 

***

This below is about xlsx package.  It didn't work well when there are already existing files of the same name.  I couldn't find ways to override.

x is the name of a R dataset.

library(xlsx)

write.xlsx(x, "temp.xlsx", sheetName="merged data",
col.names=TRUE, row.names=TRUE, append=FALSE)

https://cran.r-project.org/web/packages/xlsx/xlsx.pdf

http://www.sthda.com/english/wiki/r-xlsx-package-a-quick-start-guide-to-manipulate-excel-files-in-r

 

CategoriesR

Leave a Reply