Replicate Everything
  • Explore
  • Studies
  • Contribute

1. Choose a study


2. Tables & figures


  • Output
  • Code

Contribute a replication

Hover underlined terms for examples.

  • Add a folder under papers/
    Folder layout
                          papers/10.1017S0003055403000534/
      replication.yml
      code/tab_1.R
      data/repdata.dta
      artifacts/tab_1.rds
      artifacts/manifest.json
                        
    in the registry repository.
  • Include replication.yml
    Sample replication.yml
                          paper:
      doi: https://doi.org/10.1017/S0003055403000534
      title: Ethnicity, Insurgency, and Civil War
      dependencies:
        - haven
        - modelsummary
    
    replications:
      - id: tab_1
        type: table
        label: Table 1
        data: data/repdata.dta
        code: code/tab_1.R
        format: format_tab_1
        artifact: artifacts/tab_1.rds
                        
    , code/
    Self-contained script
                          # Paper folder: https://github.com/replicate-anything/registry/
    #   tree/main/papers/10.1017S0003055403000534
    
    library(haven)
    library(modelsummary)
    library(kableExtra)
    
    make_tab_1 <- function(data) { ... }
    format_tab_1 <- function(object) { ... }
    
    make_tab_1(haven::read_dta("../data/repdata.dta")) |> format_tab_1()
                        
    , and data/ .
  • Prefer two steps when possible: make_tab_1(data)
    Analysis function
                          make_tab_1 <- function(data) {
      glm(onset ~ warl + gdpenl + lpopl, data = data,
          family = binomial())
    }
    
    format_tab_1 <- function(object) {
      modelsummary::modelsummary(
        object,
        output = "kableExtra",
        stars = TRUE
      )
    }
                        
    for analysis and format_tab_1(object)
    Display function
                          make_tab_1 <- function(data) {
      glm(onset ~ warl + gdpenl + lpopl, data = data,
          family = binomial())
    }
    
    format_tab_1 <- function(object) {
      modelsummary::modelsummary(
        object,
        output = "kableExtra",
        stars = TRUE
      )
    }
                        
    for display. Register with format: format_tab_1
    replication.yml entry
                          paper:
      doi: https://doi.org/10.1017/S0003055403000534
      title: Ethnicity, Insurgency, and Civil War
      dependencies:
        - haven
        - modelsummary
    
    replications:
      - id: tab_1
        type: table
        label: Table 1
        data: data/repdata.dta
        code: code/tab_1.R
        format: format_tab_1
        artifact: artifacts/tab_1.rds
                        
    so artifacts store analysis output (usually .rds ). Omit format when analysis and formatting cannot be separated. Figures use make_fig_1(data)
    Figure example
                            - id: fig_1
        type: figure
        data: data/example.csv
        code: code/fig_1.R
        artifact: artifacts/fig_1.png
    
    make_fig_1 <- function(data) {
      ggplot2::ggplot(data, ggplot2::aes(x, y)) +
        ggplot2::geom_line()
    }
                        
    and save .png artifacts.
  • Scripts must be self-contained
    Script pattern
                          # Paper folder: https://github.com/replicate-anything/registry/
    #   tree/main/papers/10.1017S0003055403000534
    
    library(haven)
    library(modelsummary)
    library(kableExtra)
    
    make_tab_1 <- function(data) { ... }
    format_tab_1 <- function(object) { ... }
    
    make_tab_1(haven::read_dta("../data/repdata.dta")) |> format_tab_1()
                        
    : include library() calls, a commented link to the paper folder on GitHub, and a footer that loads data/ via a local path (works when run from code/ or the paper folder).
  • Run Rscript scripts/build_artifacts.R
    Build & validate
                          cd registry
    Rscript scripts/build_artifacts.R
    
    # one paper only:
    Rscript scripts/build_artifacts.R papers/10.1017S0003055403000534
    
    Rscript scripts/validate_artifacts.R
                        
    in the registry to precompute artifacts/ for the app.