This function exports a data frame to a specified file format, including CSV, TSV, RDS, XLSX, and TXT. If the format is not provided, it is inferred from the file extension.
Usage
export_matrix(
.data,
file,
format = NULL,
drop_extra = FALSE,
extra_columns = NULL,
silent = FALSE,
...
)
Arguments
- .data
A data frame or tibble to be exported.
- file
A character string specifying the file name and path.
- format
A character string specifying the file format. If `NULL`, the format is inferred from the file extension. Supported formats: `"csv"`, `"tsv"`, `"rds"`, `"xlsx"`, `"txt"`.
- drop_extra
Logical. If `TRUE`, removes columns not listed in `extra_columns` before exporting. Default is `FALSE`.
- extra_columns
A character vector specifying additional columns to retain if `drop_extra = TRUE`. Default is `NULL`.
- silent
Logical. If `TRUE`, suppresses messages. Default is `FALSE`.
- ...
Additional arguments passed to the underlying export functions (`write.csv`, `writexl::write_xlsx`, etc.).