write.xlsx | R Documentation |
This function calls the write_xlsx()
function in the writexl package
by Jeroen Ooms to write an Excel file (.xlsx).
write.xlsx(x, file = "Excel_Data.xlsx", col.names = TRUE, format = FALSE,
use.zip64 = FALSE, check = TRUE)
x |
a matrix, data frame or (named) list of matrices or data frames that will be written in the Excel file. |
file |
a character string naming a file with or without file extension
'.xlsx', e.g., |
col.names |
logical: if |
format |
logical: if |
use.zip64 |
logical: if |
check |
logical: if |
This function supports strings, numbers, booleans, and dates.
The function was adapted from the write_xlsx()
function in the writexl
package by Jeroen Ooms (2021).
Jeroen Ooms
Jeroen O. (2021). writexl: Export Data Frames to Excel 'xlsx' Format. R package version 1.4.0. https://CRAN.R-project.org/package=writexl
read.xlsx
, write.sav
, write.dta
,
write.mplus
## Not run:
# Example 1: Write Excel file (.xlsx)
dat <- data.frame(id = 1:5,
gender = c(NA, 0, 1, 1, 0),
age = c(16, 19, 17, NA, 16),
status = c(1, 2, 3, 1, 4),
score = c(511, 506, 497, 502, 491))
write.xlsx(dat, file = "Excel.xlsx")
# Example 2: Write Excel file with multiple sheets (.xlsx)
write.xlsx(list(cars = cars, mtcars = mtcars), file = "Excel_Sheets.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.