Skip to contents

Convenience dispatcher: routes ggplots to save_plot() and data frames / lists to save_data(), choosing by the object type. Handy at the end of a pipe when you do not want to think about which saver to call.

Usage

save_output(x, path = NULL, ...)

Arguments

x

A ggplot, a data frame, or a (named) list of data frames.

path

Output path; the extension picks the format. NULL (default) writes plot.png or data.csv. A bare file name lands in ezrsurvey-outputs/ (created on demand); a path naming a directory ("./x.png", "charts/x.png", anything absolute) is used exactly as given. See the output_dir option.

...

Passed to save_plot() or save_data().

Value

x, invisibly.

Examples

tmp_csv <- tempfile(fileext = ".csv")
calc_percentage(podracing_survey, demo_gender) %>% save_output(tmp_csv)

# \donttest{
tmp_png <- tempfile(fileext = ".png")
plot_bars(calc_percentage(podracing_survey, demo_gender)) %>% save_output(tmp_png)
# }