write.xlsx: Write Excel File

View source: R/write.xlsx.R

write.xlsxR Documentation

Write Excel File

Description

This function calls the write_xlsx() function in the writexl package by Jeroen Ooms to write an Excel file (.xlsx).

Usage

write.xlsx(x, file = "Excel_Data.xlsx", col.names = TRUE, format = FALSE,
           use.zip64 = FALSE, check = TRUE)

Arguments

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., "My_Excle.xlsx" or "My_Excel".

col.names

logical: if TRUE, column names are written at the top of the Excel sheet.

format

logical: if TRUE, column names in the Excel file are centered and bold.

use.zip64

logical: if TRUE, zip64 to enable support for 4GB+ Excel files is used.

check

logical: if TRUE, argument specification is checked.

Details

This function supports strings, numbers, booleans, and dates.

Note

The function was adapted from the write_xlsx() function in the writexl package by Jeroen Ooms (2021).

Author(s)

Jeroen Ooms

References

Jeroen O. (2021). writexl: Export Data Frames to Excel 'xlsx' Format. R package version 1.4.0. https://CRAN.R-project.org/package=writexl

See Also

read.xlsx

Examples

## Not run: 
# 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")

# Write Excel file with multiple sheets (.xlsx)
write.xlsx(list(cars = cars, mtcars = mtcars), file = "Excel_Sheets.xlsx")

## End(Not run)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to write.xlsx in misty...