Reproducible Data Embedding

Allows caching of raw data directly in R code. This allows R scripts and R Notebooks to be shared and re-run on a machine without access to the original data. Cached data is encoded into an ASCII string that can be pasted into R code. When the code is run, the data is automatically loaded from the cached version if the original data file is unavailable. Works best for small datasets (a few hundred observations).


This R package allows you to easily share (small) data sets directly in an R Notebook or other R code.


If you had a CSV file on your computer called country_pop.csv that you used in your analysis, you'd have to send it along with your code in order for the recipient to be able to re-run your analysis. However, with the rde pacakge, you can embed the data directly in your code. The code with the embedded data would look like the following.

library(rde) <- load_rde_var(
  use.cache = FALSE,
  load.fcn = {
    fname <- system.file("extdata", "country_pop.csv", package = "rde")
    read.csv(fname, stringsAsFactors = FALSE)
  cache = "

When the code above is run, load_rde_var will first try to run the code in load.fcn. If this suceeds, then tha tdata is returned. Otherwise, it loads the data from the encoded string given in the argument cache. If you send your code to someone else and don't send them the data files, when the run the code, they will be getting the data from the encoded version that is located directly in your code.

The encoded version of the data is easily produced by the function copy_rde_var.

Additionally, load_rde_var checks that the cahced value matches the result of load.fcn and tells you if there is a difference.


This package is not yet on CRAN.

# Install the development version from GitHub
# install.packages("devtools")


For more information about how to use this package, please see the tutorial, which can be accessed by running one of the following R commands:

RShowDoc("rde_tutorial", package = "rde")
# or, alternatively


Contributions to this package are welcome. Please feel free to discuss a feature that you think should be added in the Issues page on GitHub. Feel free to submit a Pull Request too. If you submit code, please make sure that it is tested.


If you discover a bug in this package, please report it by creating an Issue on GitHub. Please include a reproducible example and also include information on which version of R you are running and which version of each applicable package you have installed.


This package is released under the GPL Version 3 license.


rde 0.1.0

  • First version submitted to CRAN
  • Incorporated feedback about vignette received from @billycomtek
  • Explicitly set some default arguments
  • Corrected minor bug in decode_cache() releated to empty cache strings
  • Added check that packages listed in Suggests are available before using them in tests

rde 0.0.2

  • Added system requirements to DESCRIPTION file

rde 0.0.1

  • First release for beta testing by a few people

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.0 by Stefan Kloppenborg, 2 years ago

Report a bug at

Browse source code at

Authors: Stefan Kloppenborg [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Imports clipr

Suggests testthat, knitr, lintr, rmarkdown, spelling

System requirements: xclip ( or xsel ( for accessing the X11 clipboard

See at CRAN