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).


Overview

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

Usage

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)
 
pop.data <- load_rde_var(
  use.cache = FALSE,
  load.fcn = {
    fname <- system.file("extdata", "country_pop.csv", package = "rde")
    read.csv(fname, stringsAsFactors = FALSE)
  },
  cache = "
    rde1QlpoOTFBWSZTWQy+/kYAAIB3/v//6EJABRg/WlQv797wYkAAAMQiABBAACAAAZGwANk0RTKejU9T
    RoBoGgGjTRoBoGgaGymE0Kp+qemmkDNQ0YmJk0AA0xNADQNPUaA0JRhDTJoANAAAAAAAAEJx2Eja7QBK
    MKPPkRAx63wSAWt31AABs1zauhwHifs5WlltyIyQKAAAZEAZGQYMIZEA6ZAPHVMEB71jSCqdlsiR/eSY
    kzQkRq5RoXgvNNZnB5RSOvKaTGFtc/SXc74AhzqhMEJvdisEGVfo7UYngc0AwGqTvTHx8CBZTzE9OQZZ
    VY8KAhHAhrG4RCeilM0rXKkdpjGqyNgJwAkmnPQOMYrLlQ4YTIv0WyxfYdkd9WSWUsvggC/i7kinChIB
    l9/IwA==
  "
)

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.

Installation

This package is not yet on CRAN.


# Install the development version from GitHub
# install.packages("devtools")
devtools::install_github("kloppen/rde")

Vignette

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
vignette("rde_tutorial")

Contributing

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.

Bugs

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.

License

This package is released under the GPL Version 3 license.

News

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.

install.packages("rde")

0.1.0 by Stefan Kloppenborg, a year ago


https://github.com/kloppen/rde


Report a bug at https://github.com/kloppen/rde/issues


Browse source code at https://github.com/cran/rde


Authors: Stefan Kloppenborg [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Imports clipr

Suggests testthat, knitr, lintr, rmarkdown, spelling

System requirements: xclip (https://github.com/astrand/xclip) or xsel (http://www.vergenet.net/~conrad/software/xsel/) for accessing the X11 clipboard


See at CRAN