Skip to contents

Executes a specific replication (figure or table) for a paper, or every step in the study DAG when what = "everything" (transform, table, and figure steps; format children run only when format = TRUE).

Usage

run_replication(
  doi,
  what,
  language = NULL,
  given = NULL,
  force = TRUE,
  install_deps = FALSE,
  format = FALSE,
  repo = NULL,
  folder = NULL
)

Arguments

doi

Character. DOI, registry handle, or local study path (see resolve_doi_input()). Pass "local" to run against the study in the current working directory — no registry lookup is needed.

what

Character. Step or replication identifier (e.g. "tab_1"), or "everything" to run all non-format steps in the study DAG.

language

Optional "R", "stata", or "python". When omitted and the replication has only one engine, that engine is used automatically. When both R and Stata exist for the same logical id, R is preferred unless language is set.

given

Assumed-complete steps. For a single step, defaults to "parents" (immediate parent outputs must exist). For what = "everything", defaults to "nothing" (run the full upstream DAG). May also be a character vector of step ids.

force

Logical. Re-run steps even when declared outputs/ already exist. Defaults to TRUE: run_replication() is a live Run (unlike Display / load_artifact(), which use precomputed files). Set force = FALSE to reuse existing upstream outputs when present; the target step still recomputes.

install_deps

Logical. Install missing CRAN dependencies when TRUE. Defaults to FALSE.

format

Logical or "if_available". Apply display formatting when available. When what = "everything", applies to each step in the returned list (FALSE returns raw analysis objects only).

repo

Optional repository slug.

folder

Optional registry folder name from index.csv.

Value

For a single replication, the analysis or formatted object. For what = "everything", a named list of results for every non-format step in the study DAG (invisibly).

Details

By default returns the raw analysis object (e.g. a glm or ggplot). Set format = TRUE or format = "if_available" to apply the registered format_* step when replication.yml defines one (same step used for display outputs and Shiny).

Examples

if (FALSE) { # \dontrun{
run_replication("10.1177/00491241211036161", "fig_1", format = TRUE)
run_replication("10.1017/S0003055403000534", "tab_1", format = TRUE)
run_replication("10.1017/S0003055403000534", "tab_1", language = "stata")
run_replication("10.1017/S0003055422000284", "tab_1")
run_replication("10.1257/aer.91.5.1369", "tab_1", language = "stata", format = TRUE)
run_replication("rep-template", "tab_1", format = TRUE)
run_replication("10.1177/00491241211036161", "everything")

# setwd() to a checked-out study repo (or open its RStudio project) and
# run a step against it directly — no DOI or registry lookup required.
setwd("path/to/rep-my-study")
run_replication("local", "tab_1")
run_replication("local", "fig_1", format = TRUE)
} # }