Skip to content

Instantly share code, notes, and snippets.

@jeromyanglim
Created April 16, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromyanglim/c553b913b20dedaf6c4dc8e750c6d4db to your computer and use it in GitHub Desktop.
Save jeromyanglim/c553b913b20dedaf6c4dc8e750c6d4db to your computer and use it in GitHub Desktop.
# Function to write data.frame to xlsx spreadsheet
write_xlsx <- function(data, file, sheetname = "Sheet1", rowNames = TRUE, ...) {
require("openxlsx")
wb <- createWorkbook()
addWorksheet(wb, sheetname)
writeData(wb, sheetname, data, rowNames = rowNames, ...)
saveWorkbook(wb, file = file, overwrite = TRUE)
}
# Example
# data(cars)
# write_xlsx(cars, "cars.xlsx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment