Search code examples
rexcelsavesaving-data

Is it possible to create an Excel file with R?


General question: is there an R package out there that creates an Excel file? Or saves data frames as excel files? Or is it only possible to write files that already exist in a specific directory? If it is possible to create new Excel files, is there also a possibility to create multiple Excel sheets in that file?

Thank you for answering!


Solution

  • I believe the package openxlsx is the most popular package to do this.

    Example:

    library(openxlsx)
    write.xlsx(iris, file = "writeXLSX1.xlsx")
    

    And yes, you can also add multiple sheets. See a nice introduction here.