knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(readr)
library(fertile)

fertile: creating optimal conditions for reproducibility

Goal

Why do we need this?

What is it?

Prospective Reproducibility

"I'm fiddling with pineapple coconut cake recipes,... but I want someone else to be able to follow my steps."

Logs your actions

log_clear()
library(fs)

read_csv("data.csv")
read_csv("../tests/testthat/data/data.csv")
log_report()

Checks paths

readr::read_csv("../fertile/tests/testthat/data/data.csv")
fertile::read_csv("../fertile/tests/testthat/data/data.csv")
read_csv(tempfile())

write_csv(data.frame(a = 1), file = tempfile())
write_csv(data.frame(a = 1), file = "temp_data.csv")
log_report()

Prevents you from doing bad things

setwd("vignettes")

Works by shimming many I/O functions

?shims

Retrospective Reproducibility

"I've baked a pineapple cococnut cake. What was my recipe?"

A simple project

unzip(system.file("extdata/project_noob.zip", package = "fertile"), exdir = "../tests/testthat")
project_noob <- here::here("tests", "testthat", "project_noob")
fs::dir_info(project_noob)

Test it

proj_test(project_noob)

A slightly more complicated project

unzip(system.file("extdata/project_miceps.zip", package = "fertile"), exdir = "../tests/testthat")
project_miceps <- here::here("tests", "testthat", "project_miceps")
fs::dir_info(project_miceps)
x <- proj_analyze(project_miceps)
x
proj_suggest_moves(x$suggestions)
proj_move_files(x$suggestions)
fs::dir_info(project_miceps)
fs::dir_delete(project_noob)
fs::dir_delete(project_miceps)

Moving forward

Questions



baumer-lab/fertile documentation built on April 19, 2021, 12:01 a.m.