The Publisher

S27 · Chapter 14

Today’s Agenda

  • Why copy-and-paste is fragile
  • A report that rebuilds itself
  • IMRaD
  • Publishing the site

Today’s Starter File

Where the Study Stands

  • You have a question, a theory, and a tested codebook
  • You have a defensible sample and a clean dataset
  • You have three figures, and a test you ran in the Inference Lab
  • The hardest parts are behind you, and the study is still not done

Scattered across a dozen files, the study is raw material, not a report.

The Fragile Way to Write It Up

  • Run the analysis in R
  • Copy the numbers into a word processor
  • Screenshot the figures and paste them in
  • Write the prose around them

This works, and it is quietly fragile. Change one coding rule and every pasted number is silently out of date, with nothing to tell you so.

A Report That Rebuilds Itself

  • Stop copying. Put the analysis inside the document
    • A Quarto document interleaves prose with code chunks
    • Rendering runs every chunk and places its output where the chunk sits
  • Tables, figures, and statistics all arrive from the code

Nothing is typed by hand, so nothing can fall out of date.

Numbers Computed Inline

The analysis dataset held `r nrow(analysis)`
coded messages, of which `r n_labeled` carried
a gaming-status label.
  • n_labeled comes from a chunk above the sentence:
n_labeled <- analysis %>%
  filter(!is.na(is_gaming)) %>%
  nrow()
  • Those backtick expressions become the actual counts in the rendered report
  • Add a hundred messages to the data, re-render, and the sentence updates itself

Figures Produced, Not Pasted

#| label: fig-msglen
#| echo: false
#| fig-cap: "Message length by channel type."
#| fig-alt: "YOUR TURN: what this chart shows."
analysis %>%
  filter(!is.na(is_gaming)) %>%
  ggplot(aes(x = message_length, fill = is_gaming)) +
  geom_histogram(binwidth = 5) +
  v2v::theme_v2v()

The histogram is a chunk that redraws itself on every render. echo: false hides the code and shows only the plot.

Exercise: The Typed Number

  • A draft sentence, typed by hand: “Non-gaming messages averaged 33.7 characters; gaming messages averaged 28.5”
  • Next week the data gain 200 more coded messages
  • Which numbers in that sentence are now wrong, with nothing in the report to warn you?

Why a Reproducible Report Matters

  • The report cannot drift from the analysis, because the report is the analysis
  • Anyone with your source files and your data can render your results
    • That is the standard a scientific claim is meant to meet
  • Knuth named this idea literate programming in 1984
    • Runnable code and the prose that explains it belong in one document

IMRaD, the Shape of a Report

Introduction, Methods, Results, Discussion, in that fixed order.

  • It carries a reader from why, to what was done, to what was found, to what it means
  • An abstract sits in front, and the references close it
  • new_portfolio() already created the section files: 01-introduction.qmd through 05-reflection.qmd, with index.qmd for the abstract and references.qmd

Introduction and Methods

  • Introduction: the question, and why it is worth asking
    • For the example study: do the two kinds of channel differ in message length, and what does theory lead you to expect?
  • Methods: what was done, in enough detail for someone else to repeat it
    • The codebook, the sampling, the reliability check, and the wrangling
  • Methods is the section that earns the reader’s trust

Results and Discussion

  • Results: what was found, without interpretation
    • The figures, the group means, and the test with its degrees of freedom, p, and effect size
  • Discussion: what the result means, and the study’s limits
    • For the example study: a real difference, but a negligible one
  • A model write-up for each test: Chapter 13

One Book, Many Chapters

  • The report is not the only document the study produced
    • The codebook, the sampling record, and the wrangling log are documents too
  • They become chapters of one Quarto book, not one enormous file
  • _quarto.yml lists the chapters in order: the five section files, the references, and the codebook and journal as appendices
  • Rendering the project builds every chapter into one website and one PDF: Step 10 of the Chapter 14 starter file runs it

Going Live

  • A site in a folder on a laptop is still private
    • Publishing means giving the site a public address
  • The standard free option is GitHub Pages
  • Your paper’s address goes into the White Paper submission, beside one ZIP file holding the paper PDF and your AI-use log

Publish in Two Steps

  • Commit and push first: Commit and Push with Git
  • Then v2v::deploy_portfolio(project) runs the checks and publishes the site: Steps 12 and 13 of the Chapter 14 starter file
    • project is your White Paper folder’s name, set in Step 2 of that file
  • When it finishes, your paper is live at your repository’s GitHub Pages address

The Pre-Flight Checks

v2v::deploy_portfolio(project)
── Pre-flight checks ──
ℹ No renv.lock found - skipping renv check
✔ no uncommitted changes
✔ _quarto.yml valid
──────────────────────
✔ Rendering 9 pages
Publish to GitHub Pages? [y/N] y
✔ Publishing to GitHub Pages
ℹ Published to https://your-username.github.io/your-repository/
✔ Portfolio live on GitHub Pages.

The Pre-Flight Checks (cont.)

  • Commit and push first, or the second check stops you (Commit and Push with Git)
  • Three checks run first. Only if none fails does the book render
  • It publishes only after you click in the R terminal, type y, and press Enter
  • The renv check is skipped here because the course scaffold has no renv.lock

What renv Is

renv: an R package that records the exact version of every package your project uses in a file called renv.lock, so those same versions can be installed again later. Example: the first pre-flight check compares your installed packages against renv.lock.

Why the Checks Exist

  • renv in sync: the site is built with the package versions your source declares, checked only when the project has a renv.lock
  • No uncommitted changes: every saved change is also committed (a snapshot Git records and sends to GitHub), so the live site matches your files
  • _quarto.yml found: R is pointed at your White Paper folder, not the workspace around it
  • Each check heads off one specific, demoralizing failure

The last step of a long study should be the calm one.

Before Next Time

Coming Due

Questions, Comments, or Concerns?