MyNixOS website logo
Description

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

Reproducible Data Exchange (rde)

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.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows