Package 'ggdatasaver'

Title: Automatically save data associated with a 'ggplot2' plot
Description: Automatically create a file with the data used to create a 'ggplot2' plot. Each layer's data is saved in its own csv file inside a compressed file. These files can then be published as supplemental material so that other people can re-do your plots without the need of digitising them. Because the only data that is saved is the one that is shown in the plot, there are fewer privacy concerns.
Authors: Elio Campitelli [cre, aut]
Maintainer: Elio Campitelli <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-08-27 03:08:20 UTC
Source: https://github.com/eliocamp/ggdatasaver

Help Index


Saves data associated with a ggplot plot

Description

Takes a ggplot and saves a zip file with a single csv file for each layer of the plot with the data used by said layer

Usage

save_plot_data(plot, name = "plot", dir = ".")

Arguments

plot

A ggplot2 plot.

name

The name used as file name.

dir

Directory where to put the file. If NUL

In general, you don't need to call this function explicitly, since it will be used automatically by knitr if the plot data directory is set (see save_plot_data_in()).

Paraphrasing Voltaire, if dir doesn't exist, it will be created. If the file already exists, it will be overwritten without a warning. This is because this function is supposed to run with knitr every time a document is knit and will update the data to the latest version.


Set the data directory

Description

Set the directory where data assocaited with plots will be saved.

Usage

save_plot_data_in(dir = NULL)

Arguments

dir

A directory where to save plot data. If NULL, plot data will not be saved.

This functions sets the plot_data_dir chunk option in knitr. You can get the same behaviour with knitr::opts_chunk$set(plot_data_dir = dir). However, if you use that code, you'll need to call library(ggdatasaver) explicitly for the package to work.