Title: | Automated Reproducibility Checks for R Markdown Documents |
---|---|
Description: | Provide reproducible R chunks in R Markdown document that automatically check computational results for reproducibility. This is achieved by creating json files storing metadata about computational results. A comprehensive tutorial to the package is available as preprint by Brandmaier & Peikert (2024, <doi:10.31234/osf.io/3zjvf>). |
Authors: | Andreas M. Brandmaier [aut, cre], Aaron Peikert [ctb] |
Maintainer: | Andreas M. Brandmaier <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.3 |
Built: | 2025-03-28 06:21:36 UTC |
Source: | https://github.com/brandmaier/reproduciblerchunks |
Get the total number of failed reproduction attempts
get_num_reproducibility_errors(envir = .cache)
get_num_reproducibility_errors(envir = .cache)
envir |
Environment to retrieve data from. This defaults to a internal package namespace. |
Returns the number of errors encountered when reproducing a Markdown document
This function returns a data frame, in which details
about reproduction attempts are collected. The data frame has
three columns named "Chunk","Variable", and "Success". Every row
in the data frame corresponds to one variable, for which reproducibility
was tested. Chunk
stores the name of the surrounding chunk, Variable
stores the name of the variable, and Success
is a boolean variable,
which indicates whether the reproduction attempt was successful.
get_reproducibility_summary(envir = .cache)
get_reproducibility_summary(envir = .cache)
envir |
Environment to retrieve data from. This defaults to a internal package namespace. |
Returns a data.frame with three columns.
Test reproducibility of an R Markdown file
isReproducible(filename, resetOptions = TRUE, ...)
isReproducible(filename, resetOptions = TRUE, ...)
filename |
Character. An R Markdown file to check for reproducibility |
resetOptions |
Boolean. Should all package options be reset to defaults? TRUE by default. This avoids problems if multiple checks on multiple documents with varying options are made in a row |
... |
Optional arguments passed down to |
This function loads reproducibility meta data from a file and stores the meta information about the variable contents in the specified environment. Reproducibility meta data can be loaded from either a json (preferred) or a binary saved R object. The function returns a named list with meta information restored from file. The named elements include "hashing" indicating whether a hashing algorithm was used, "hashing_algorithm" indicating the name of the hashing algorithm, "hashing_package" indicating the name of the R package, from which the hashing algorithm was used, "hashing_package_version" indicating the package version, "digits" the numeric precision used before hashing numeric values, and "code_fingerprint" the actual hashed string of the chunk code.
load_repro_data(filename, envir, filetype = c("json", "rda"))
load_repro_data(filename, envir, filetype = c("json", "rda"))
filename |
Character. File name to load objects from. |
envir |
Environment to load the objects into. By default, this is the global environment. |
filetype |
Character. Currently supported is json and rda. |
Returns a named list with meta information restored from file. See description for more details.
This is the main RMarkdown chunk hook for processing the automated reproducibility tests of code chunks. This function is not intended to be called directly. Rather, it is expected that RStudio calls this function when rendering chunks with the label identical to this function name.
reproducibleR(options)
reproducibleR(options)
options |
A list of chunk options passed from the knitr engine. Usually this is just the object options passed to the engine function; see knit_engines. |
This function first executes the R code from a given chunk. If a variable is declared within the scope of the chunk, meta information about the variable's content are generated. If no metadata exists, this metadata is stored in a separate file. If metadata exists, it is compared against the metadata of the reproduction attempt.
A character string generated from the source code and output.
Andreas M. Brandmaier
reproducibleR(knitr::opts_chunk$merge(list(engine="reproducibleR",code="1+1")))
reproducibleR(knitr::opts_chunk$merge(list(engine="reproducibleR",code="1+1")))
Storing reproducibility data
save_repro_data( x, filename, filetype = default_filetype(), envir = NULL, extra = NULL )
save_repro_data( x, filename, filetype = default_filetype(), envir = NULL, extra = NULL )
x |
Object to be stored. |
filename |
Name (possible including full path) of the save file |
filetype |
Character. Currently supported is json and rda. |
envir |
Environment to load the objects into. By default, this is the global environment. |
extra |
List. Extra payload to store in the meta data |
No return value