A pipe-friendly one-liner for dropping a summary table to disk. The format is
taken from the file extension. For .xlsx, pass a single data frame for one
sheet, or a named list of data frames to write one sheet per element.
Returns its input invisibly so it can sit mid-pipeline.
Arguments
- data
A data frame / tibble, or (for
.xlsx) a named list of them.- path
Output path; the extension sets the format (
.csv,.tsv,.xlsx).NULL(default) writesdata.csv. A bare file name lands inezrsurvey-outputs/(created on demand); a path naming a directory ("./x.csv","charts/x.csv", anything absolute) is used exactly as given. See theoutput_diroption.- na
String to write for missing values. Default
"".- ...
Passed to the underlying writer (
readr::write_csv()/readr::write_tsv()/writexl::write_xlsx()).
Details
The format follows the file extension: .csv/.tsv via readr, .xlsx
via the suggested writexl package. For an Excel workbook, pass one data
frame for a single sheet, or a named list of data frames for one sheet each.
Returns its input invisibly so it can sit mid-pipeline. To send several
separate calls to their own tabs in one line, see export_xlsx().
See also
save_plot(), save_output(), export_xlsx().
Other save:
export_summary_xlsx(),
export_xlsx(),
save_output(),
save_plot()
Examples
tab <- calc_percentage(podracing_survey, demo_gender)
tmp <- tempfile(fileext = ".csv")
save_data(tab, tmp)
file.exists(tmp)
#> [1] TRUE
