# PLAN.md

Overall plan for translating *Learning Statistics with R* into a
self-contained Quarto book. See [AGENTS.md](AGENTS.md) for repository
conventions and the source-material overview.

## Goal

A Quarto book that is as faithful as possible to `_original-text` (the
LaTeX source), but self-contained and executable: real R code producing
real output, real figures generated at render time rather than pre-baked
`.eps` files, while preserving the original's presentation choices
(including manually-truncated output) wherever practical.

## Guiding principle

**First pass = faithful port. Second pass = fix issues.** Do not correct
spelling, wording, or statistical errors encountered in `_original-text`
while translating — record them in the [Issues to address](#issues-to-address-second-pass)
table below and move on. This keeps the first pass reviewable against the
original and avoids mixing "translation" diffs with "correction" diffs.

## Phase 0 — Scaffolding (done)

- [x] Minimal `_quarto.yml` book project at repo root.
- [x] GitHub Actions workflow (`.github/workflows/publish.yml`) publishing
      to `gh-pages` on push to `main`.
- [x] `AGENTS.md` documenting source layout and translation rules.

## Deployment: custom domain, cover image, and social metadata (done)

- [x] Custom domain (`dev.learningstatisticswithr.com`) fixed so it survives
      every future publish. **Root cause:** a `CNAME` file had only ever been
      created directly on the `gh-pages` branch (twice, historically), but
      `quarto-dev/quarto-actions/publish@v2` fully regenerates `gh-pages`
      from `main`'s rendered output on every run, silently discarding
      anything not part of that output. **Fix:** committed a `CNAME` file
      (containing `dev.learningstatisticswithr.com`) to the repo root on
      `main`, alongside `_quarto.yml`. Quarto recognises a root-level
      `CNAME` as a site resource and copies it into `_book/` on every
      render, so it now survives every future publish automatically. See
      the "Build & deploy" section of [AGENTS.md](AGENTS.md) for the
      durable explanation.
- [x] Added `site-url: "https://dev.learningstatisticswithr.com"` under
      `book:` in `_quarto.yml`, so Quarto's sitemap/canonical-URL handling
      and any absolute links it generates resolve to the custom domain
      rather than a relative or `github.io` URL.
- [x] Enabled `open-graph: true` and `twitter-card: true` under `book:` so
      links to the site render rich previews (title/description/image) on
      social platforms and chat apps.
- [x] Added a cover image, generated from an updated version of the
      original book's cover script:
  - [cover/cover-graphic.R](cover/cover-graphic.R) is adapted from
    `_original-text/cover/coverGraphic4.R` (which produced `cover6.png`,
    the cover for v0.6 of the original PDF book). Two changes: (1) dropped
    the "(version 0.6)" text from the subtitle, since the Quarto edition
    isn't versioned that way and a hardcoded version number would
    immediately go stale; (2) replaced the interactive
    quartz/R.app-plus-`dev.print()` workflow (the original script's own
    comment says "Run in R.app not Rstudio") with a headless `png()`
    device, and swapped the font family from "Arial Black"/"Arial" (not
    reliably available outside macOS/Windows) to "Liberation Sans" (a
    metric-compatible, cross-platform substitute, rendered bold via
    `font = 2`), so the cover can be regenerated headlessly on any
    platform, including this project's Linux CI.
  - The script reads its background photo directly from
    `_original-text/cover/jasmine.png` (read-only reference material)
    rather than duplicating the ~10MB file elsewhere in the repo.
  - Committed both outputs: `cover/cover.png` (full resolution,
    1883×2517, used as `book: cover-image`) and `cover/cover-social.jpg`
    (a smaller 630×842 resize, used for the `open-graph.image`/
    `twitter-card.image` overrides so social cards don't have to load a
    multi-megabyte PNG).
  - Wired `cover-image`, `cover-image-alt`, `open-graph.image` and
    `twitter-card.image` into `_quarto.yml`.
  - **Gotcha logged for visibility:** the first attempt at
    `cover-image-alt` used double quotes around the nested book title
    (`"...for "Learning Statistics with R..."..."`). That broke Quarto's
    `fig-alt` attribute parsing and leaked the raw
    `{.quarto-cover-image fig-alt=...}` text into the visible rendered
    page instead of becoming an `alt` attribute. Fixed by using single
    quotes around the nested title instead. Worth remembering if
    `cover-image-alt` (or any other attribute-bearing YAML string) is
    edited again.

## Phase 1 — Structure

- [x] Decide part/chapter structure in `_quarto.yml` mirroring the 6 parts
      + 17 chapters of `_original-text` (see chapter table in AGENTS.md).
      Part titles taken verbatim from `\part{...}` commands in
      `_original-text/pdf/lsr.tex`. Epilogue/prelude/wrapup front-and-back
      matter deliberately left out of the skeleton for now (tracked as an
      open question below).
- [x] Create one placeholder `.qmd` per chapter (`01-whystats.qmd` …
      `17-bayes.qmd`) with correct title and numbering, wired into
      `_quarto.yml`, before filling in content.
- [x] Decide how the prelude and epilogue/wrapup content map onto the
      Quarto structure, and how front matter (preface, dedication,
      abstract) fits in. **Decision:**
  - `prelude4.tex` ("Prelude to Part IV") introduces *only* Part IV
    ("Statistical theory") and is substantive content, not book-wide
    front matter. Quarto lets a `part:` entry point at a `.qmd` file
    instead of a bare string, which renders as an unnumbered
    part-introduction page before the part's first numbered chapter.
    Used that mechanism: `part-04-statistical-theory.qmd`.
  - `epilogue.tex` (`\chapter{Epilogue}`) and `wrapup.tex` (a short
    author's note about the incomplete reference list) both live inside
    the original's last `\part{Endings, alternatives and prospects}`,
    alongside Chapter 17. Kept that grouping: `epilogue.qmd` and
    `references.qmd` are unnumbered chapters appended after
    `17-bayes.qmd` within the same part, rather than pulled out as
    separate book-level front/back matter.
  - `wrapup.tex`'s content is really just a short note about the
    reference list, so it's folded into `references.qmd` alongside the
    book's actual bibliography (once the Phase 1 bibliography approach is
    decided), rather than kept as a separate near-empty chapter.
- [x] Decide bibliography approach (`refs.bib` / `book.bib` → Quarto
      `bibliography:` field). **Decision:**
  - `_original-text/tex/refs.bib` (697 entries) is identical to
    `_bookdown-adaptation/refs.bib`, and is the authoritative
    bibliography. Copied verbatim to `references.bib` at the repo root
    (the source files themselves stay untouched, per the read-only rule).
  - The original compiles with `\usepackage{apacite}` and
    `\bibliographystyle{apacite}` (APA author-date); the bookdown port
    used `biblio-style: apalike`. To match that in Quarto, use CSL rather
    than a LaTeX bibliography style: `csl: apa.csl` (APA 7th edition, from
    the [CSL style repository](https://github.com/citation-style-language/styles)),
    saved at the repo root, plus `link-citations: true`. Wired into
    `_quarto.yml` at the top level (`bibliography:`/`csl:` are pandoc
    options, not nested under `book:`).
  - Verified end-to-end with a throwaway `@Student1908` citation: renders
    as `Student (1908)` in-text, linked to a correctly APA-formatted
    entry in `references.qmd`'s `::: {#refs} :::` div.
  - `book.bib` (10 entries, bookdown-specific) and `packages.bib` (R
    package citations, machine-generated by `knitr::write_bib()`) are
    **not** ported yet — see follow-up below.

## Phase 2 — Chapter-by-chapter translation

For each chapter, working from `_original-text/tex/chapterNN_*.tex` as
primary source and `_bookdown-adaptation` as a secondary aid:

- [ ] Port prose, converting LaTeX markup to Quarto/Pandoc markdown
      (`\keyterm{}` → e.g. a span/class, `\label`/`\ref` → Quarto
      cross-refs, custom math commands → standard LaTeX math Quarto
      supports).
- [ ] Convert manually-typed `rblock`/`script` listings into executable
      Quarto code chunks, re-running the code rather than copying printed
      output verbatim.
- [x] For outputs the original truncated by hand, reproduce that
      truncated look deliberately rather than showing full live output.
      **Decision:**
  - The original's marker is the literal line `BLAH BLAH BLAH` (not an
    ellipsis — `grep -rn "BLAH" _original-text/tex/*.tex` turns up ~10
    instances, and none use `...`). Reproduce that exact literal marker
    for consistency, on its own line, surrounded by blank lines.
  - The original truncates in two different shapes: pure head truncation
    (show the first few lines, drop the rest — e.g. the `citation()`
    source-code example in Chapter 3) and head-*and*-tail truncation
    (show the first few and last few lines, drop the middle — e.g. the
    401-team `afl.finalists` factor print in Chapter 5). Any technique
    needs to support both.
  - There's also (at least once) a *column*-truncation case, where every
    row of tabular output gets a trailing `BLAH` appended rather than
    whole lines being dropped (the `describe(parenthood2)` table in
    Chapter 5). This is rare enough (1 occurrence found) that it's not
    worth generalizing for — handle it as a one-off manual edit when that
    chapter is translated, rather than building general column-truncation
    support.
  - Chosen technique: a **custom knitr output hook**, defined once in
    [_setup.qmd](_setup.qmd) and pulled into each chapter via
    `{{< include _setup.qmd >}}`. It reads two new chunk options,
    `trunc-head` and `trunc-tail` (number of lines to keep from the start
    / end of the real output), and splices in the `BLAH BLAH BLAH`
    marker when a chunk's real output exceeds `trunc-head + trunc-tail`
    lines. Chunks that don't set these options render their full, real
    output as normal — truncation is opt-in per chunk, chosen to match
    what the original happened to truncate, not applied automatically.
  - This was chosen over (a) hand-editing captured output via
    `results: asis`, which would mean copy-pasting real output into the
    document and defeats the "prefer live execution" rule, and (b)
    splitting a truncation point into two separately-evaluated chunks,
    which is fiddlier to keep in sync with a single execution and doesn't
    handle the head-and-tail case cleanly.
  - Verified with a throwaway `1:100` chunk using `trunc-head: 3` /
    `trunc-tail: 2`: real output rendered, correctly truncated with the
    marker in the middle.
  - Every chapter `.qmd` should start with `{{< include _setup.qmd >}}`
    once real content translation begins (not yet added to the
    placeholders, since they have no code chunks yet).
- [ ] Regenerate figures from `_original-text/scripts/*Images.R` /
      `_bookdown-adaptation/scripts/` as live chunks producing figures
      inline (ggplot2 or base R, matching original style as closely as
      reasonable), rather than embedding pre-rendered images.
- [ ] Port any datasets used (`_original-text/data/*.Rdata`) into a
      consistent location for the new book (e.g. `data/`) and load them
      the same way in every chapter.
- [ ] Convert LaTeX `\footnote{}` calls to Quarto **margin notes**
      (`[text]{.aside}` or a `::: {.column-margin}` div), not footnotes.
      The book uses footnotes liberally, almost always for a humorous or
      informative parenthetical remark — the intent is for the aside to
      sit next to the relevant text, which margin notes preserve and
      endnotes/footnotes (pushed to the bottom of the page or chapter) do
      not. Apply this consistently across all chapters.
- [ ] Note any content present in `_bookdown-adaptation` but missing from
      `_original-text` (or vice versa) that needs a judgment call.
- [ ] Decide whether to auto-generate an R-package citation file (e.g. via
      `knitr::write_bib()`) once real chunks are executing and add it as a
      second `bibliography:` entry alongside `references.bib`, so live
      code can cite the packages it actually uses.

## Phase 3 — Whole-book pass

- [ ] Check cross-references, numbering, and the table of contents render
      correctly end-to-end.
- [ ] Confirm the book renders cleanly via `quarto render` and the GitHub
      Actions workflow deploys successfully.
- [ ] Skim for consistency of code style/output formatting across chapters
      (this is about presentation consistency, not correctness — content
      fixes stay in Phase 4).

## Phase 4 — Second pass: fix issues

- [ ] Work through the [Issues to address](#issues-to-address-second-pass)
      table below, fixing spelling, wording, and statistical errors
      identified during Phases 1–3.
- [ ] Decide whether/how to note substantive corrections (e.g. a changelog
      or footnote) versus silently fixing typos.

## Proof of concept: Chapter 5 (Descriptive statistics)

Translated in full as a proof of concept exercising citations, margin
notes, truncated output, and the dev `lsr` package together (see
[05-descriptives.qmd](05-descriptives.qmd)). Notes for translating the
remaining chapters:

- **Data files**: copied the `.Rdata` files this chapter needs into
  `data/` at the repo root (`aflsmall`, `clinicaltrial`, `parenthood`,
  `parenthood2`, `anscombesquartet`, `effort`, `work`). `load()` calls use
  `data/whatever.Rdata` instead of the original's bare filename. Do this
  for each chapter as it's translated, rather than copying all of
  `_original-text/data/` up front.
- **Margin notes**: turned out to need almost no conversion work. The
  book already uses Pandoc's native footnote syntax (`^[...]`) for most
  asides (`\FOOTNOTE`/`\footnote{}` are the exception and become `^[...]`
  too), and setting `reference-location: margin` once, book-wide, in
  `_quarto.yml` is enough to send every footnote to the margin instead of
  the end of the document. No per-footnote markup changes needed.
- **Figures**: regenerated the figures this chapter could compute
  directly from data as live base-R plots (the AFL margins histogram,
  the three parenthood histograms, the two `dan.sleep`/`baby.sleep`
  scatterplots, the four-panel Anscombe's quartet). The original also has
  several purely *pedagogical* illustrations built from bespoke simulated
  data by `_original-text/scripts/descriptiveImages.R` (mean-vs-median
  balance diagram, skewness/kurtosis shape panels, the correlation
  strength grid, the ordinal-relationship diagram) — these were **not**
  reproduced in this pass; left as prose-only for now. Follow-up: decide
  whether to port `descriptiveImages.R`'s logic into live chunks for
  these, chapter by chapter, as they come up (they recur in later
  chapters too).
- **R/CI environment**: `psych` (a dependency introduced by this chapter)
  needs compiled Fortran code (via `mnormt`) to build from source, which
  isn't always available (it wasn't in this session's sandbox). Installed
  it with `pak::pak()` instead of `install.packages()` — pak correctly
  picked up the pre-built binary from Posit Package Manager and avoided
  the compiler dependency entirely. Recommend `pak` over base
  `install.packages()` for any package installation in this project
  going forward, for the same reason.
- **CI gap fixed**: [.github/workflows/publish.yml](.github/workflows/publish.yml)
  had no R setup step at all — it would have failed outright once any
  chapter had live R code. Added `r-lib/actions/setup-r` and
  `r-lib/actions/setup-r-dependencies`, installing `psych` and
  `djnavarro/lsr@dev` explicitly. This list will need to grow as more
  chapters are translated and pull in more packages; consider switching
  to a `DESCRIPTION`-file-based or `renv.lock`-based dependency list once
  the package set stabilises, rather than hand-maintaining the
  `packages:` block in the workflow.
  - **2026-07-12 update:** switched the workflow from tracking
    `djnavarro/lsr@dev` (a moving branch ref) to pinning
    `djnavarro/lsr@b4e9a88`, the commit that merged
    [lsr#25](https://github.com/djnavarro/lsr/pull/25) — the fix set that
    came out of the 1.0.0 release-candidate stress test (see
    [PACKAGE-NOTES.md](PACKAGE-NOTES.md)). Pinning to a SHA means CI
    renders stop silently picking up further `dev`-branch changes; bump
    this pin deliberately (and re-render affected chapters) whenever a
    new upstream fix needs to land in the book.

## Chapter 6 (Drawing graphs)

Translated in full (see [06-graphics.qmd](06-graphics.qmd)), building directly on the
Chapter 5 proof-of-concept conventions. Notes:

- **New dependencies**: `HistData` (for the John Snow cholera map figure) and `car`
  (for `scatterplot()`/`Boxplot()`) weren't previously needed. Installed both locally
  via `pak::pak()`, consistent with the `lsr`/`psych` precedent in Chapter 5, and
  added to the CI workflow's package list (see [.github/workflows/publish.yml](.github/workflows/publish.yml)),
  alongside `lsr` and `psych`.
- **Data files**: added `aflsmall2.Rdata` to `data/` (needed for the
  multi-year boxplot figure); `aflsmall.Rdata` and `parenthood.Rdata` were already
  present from Chapter 5.
- **Figures**: every figure in this chapter is regenerated live, including the John
  Snow cholera map (using `HistData::SnowMap()`, matching the approach the bookdown
  adaptation already used) — none of this chapter's figures needed the
  bespoke-simulated-data treatment flagged as a follow-up in Chapter 5's notes.
  Multi-panel figures that the original showed side-by-side with no intervening prose
  (the `pch`/`lty` reference grid, and the two "too few/too many bins" histograms)
  use Quarto's `fig-subcap`/`layout-ncol` inside a single chunk, following the pattern
  already established for Chapter 5's Anscombe's-quartet panel. Figures whose
  panels are introduced across separate paragraphs (histograms a/b/c/d, boxplots,
  bar graphs a/b/c/d) are instead rendered as separate individual figures at the
  point each is discussed, rather than forced into a single multi-panel figure —
  simpler and more robust than trying to reconstruct the original's exact print-layout
  groupings.
- **Hand-annotated figure omitted**: the original's boxplot-anatomy diagram (arrows
  and labels pointing at the median/box/whiskers, added by hand rather than by any
  R command) is not reproduced; a footnote on the basic boxplot figure explains the
  omission and the prose covers the same content. Same rationale as the
  pedagogical/hand-built figures skipped in Chapter 5.
- **Cross-references (added retroactively)**: this chapter also had four plain-bracketed-text placeholders (`[R mechanics]` ×2, `[Data handling]` ×2) referencing chapters that were still untranslated placeholders at the time. Converted to real `@sec-mechanics`/`@sec-datahandling` cross-refs now that chapters 4 and 7 are translated — found and fixed alongside the same cleanup for Chapters 5, 7 and 8 (see Issues table).
- **Presentational accommodation**: the "ugly details" subsection's `dev.list()` /
  `dev.print()` walkthrough is inherently OS- and device-specific (`windows` vs.
  `quartz` vs. `RStudioGD`, actual JPEG files written to disk) and can't be
  faithfully executed in this book's headless Linux CI. Kept as a non-executed,
  illustrative code transcript (as the original itself frames it as a
  Windows/Mac-specific example) rather than a live chunk — logged here for
  transparency, not because anything was "fixed."
- **Outlier-detection walkthrough**: the original temporarily corrupts
  `afl.margins[137]` to `333` to demonstrate outlier-spotting, then "fixes" it back
  to `33`. Checked against the real `aflsmall.Rdata`: index 137's true value really
  is `33`, so this is a faithful reproduction of the original's real R session, not
  a hypothetical — no special handling needed beyond replicating the same
  assignment/restore sequence.

## Chapter 7 (Pragmatic matters / data handling)

Translated in full (see [07-datahandling.qmd](07-datahandling.qmd)), the longest chapter so far. Notes:

- **Data files**: added `nightgarden.Rdata`, `nightgarden2.Rdata`, `likert.Rdata`, `cakes.Rdata`, `repeated.Rdata` (contains `choice` and `drugs`), and `booksales2.csv` to `data/`.
- **Package functions**: this chapter is the first to lean heavily on `lsr`-specific helpers beyond `who()` — `quantileCut()`, `sortFrame()`, `tFrame()`, `rowCopy()`/`colCopy()`, `importList()`, `wideToLong()`/`longToWide()`. All confirmed present and working on the dev branch already pinned for this project (see "Package dependency: `lsr`" below).
- **`importList()` interactivity**: the original shows `importList()` pausing to ask `Create these variables? [y/n]` at the console. That prompt can't be answered in a non-interactive render, so the live chunk uses `importList(speech.by.char, ask = FALSE)` with an inline note explaining the change; the original console transcript showing the prompt is kept as a non-executed code block immediately below for faithfulness.
- **`booksales2.csv` "quirky CSV" figure omitted in favour of live code**: the original shows a picture of the file (`booksales2csv.eps`) as it looks in a spreadsheet program, to illustrate its nonstandard quoting/separator/skip/NA-string conventions. Rather than reproduce that screenshot as a static image, the translation prints the raw file contents directly via `cat(readLines(...))`, which conveys the same "quirky formatting" information but is live and executable rather than a picture. Logged here since it's a presentational substitution, not a content fix.
- **Non-executable illustrative code kept as `eval: false`**: several subsections describe loading file types this book's data set doesn't include examples of (SPSS `.sav` via `foreign::read.spss()`, Excel via `gdata::read.xls()`, Matlab `.mat` via `R.matlab::readMat()`). These are kept as non-evaluated code blocks, matching the precedent set in Chapter 6 for the OS-specific `dev.list()`/`dev.print()` walkthrough.
- **Tables**: the mathematical-functions, arithmetic-operator, escape-character, and ASCII-ordering tables are all hand-written Quarto/pandoc markdown tables (with `: Caption {#tbl-id}` syntax) rather than `knitr::kable()`, consistent with the plain-markdown-table convention already used in earlier chapters.
- **Cross-references**: this chapter defines several section ids referenced by earlier chapters (`#sec-matrix`, `#sec-datastructures`). Its own references to `[Getting started with R]`, `[R mechanics]` and `[Drawing graphs]` have since been converted to real `@sec-introR`/`@sec-mechanics`/`@sec-graphics` cross-refs now that chapters 3, 4 and 6 are translated (see the Issues table below).

## Chapter 8 (Basic programming / scripting)

Translated in full (see [08-scripting.qmd](08-scripting.qmd)). Notes:

- **New `scripts/` directory**: this chapter is the first to introduce actual script files as first-class content (`hello.R`, `itngscript.R`, `silenthello.R`, `whileexample.R`, `forexample.R`, `forexample2.R`, `mortgage.R`, `ifelseexample.R`, `functionexample.R`, `functionexample2.R`, `functionexample3.R`), added at the repo root as `scripts/`, mirroring the `data/` convention. Each chunk shows the script's contents as a non-executed (`eval: false`) code block labelled `## --- filename.R` (following the `_bookdown-adaptation` convention, since the original's `\scriptname{}`/`\begin{script}` LaTeX macros have no direct Quarto equivalent), immediately followed by a live chunk that actually `source()`s the real file from `scripts/`, so the printed output is genuinely executed rather than transcribed.
- **Mortgage loop example**: verified `scripts/mortgage.R` reproduces the original's numbers exactly (356 months, final balance -1554, total payments 569600), so the original's `BLAH BLAH BLAH` truncation (head 5 lines / tail 6 lines, keeping the final `total payments made` line) was reproduced with `trunc-head: 5` / `trunc-tail: 6` chunk options rather than a content fix.
- **Date-dependent conditional example**: the `ifelseexample.R` script's `if (day == "Monday")` illustration depends on the real system date at render time (originally "Since today happens to be a Tuesday" in the fixed print book). Followed the `_bookdown-adaptation` precedent of substituting an inline `` `r weekdays(Sys.Date())` `` expression instead of hardcoding a day name, so the prose and the live `source()` output always agree, whatever day the book happens to render.
- **Epigraph attribution omitted**: the LaTeX source has the William Gibson quote's page/book attribution (`Count Zero`, 1986) commented out (`%, Count Zero (1986`), unlike Chapter 7's Zelazny epigraph where the equivalent footnote is live in the `.tex`. Followed the LaTeX literally and left the attribution out, even though `_bookdown-adaptation` includes it as a footnote — logged here since it's a visible divergence from the bookdown port, not an oversight.
- **Rstudio-specific screenshots omitted**: the two screenshots showing `hello.R` open in a plain text editor and in Rstudio (illustrating that a script is "just an ordinary text file" and demonstrating syntax highlighting) are dropped, with a short footnote explaining the omission — same rationale as the hand-annotated/screenshot figures skipped in Chapters 5–6. Added a footnote noting Positron (this book's own authoring environment) as the modern equivalent of the Rstudio-specific advice in this section, since it seemed a useful, low-risk aside rather than a content correction.
- **Cross-references**: forward/backward chapter references to `[Getting started with R]`, `[R mechanics]` and `[Pragmatic matters]` have since been converted to real `@sec-introR`/`@sec-mechanics`/`@sec-datahandling` cross-refs now that chapters 3, 4 and 7 are translated (see the Issues table below).

## Chapter 3 (Getting started with R)

Translated in full (see [03-introR.qmd](03-introR.qmd)). Notes:

- **No new data files or packages**: this chapter predates the book's data sets, so nothing was added to `data/`, and no new package dependencies were introduced.
- **Installation instructions kept faithful, including outdated version numbers**: the sections on downloading/installing R (3.0.2, "Frisbee Sailing") and Rstudio (0.98.501 beta) are translated verbatim, per the "faithfulness first" rule — see the Issues table below for the follow-up to revisit this in Phase 4.
- **Six screenshots omitted**: the Rstudio session screenshot, two autocomplete-popup screenshots, the command-history-panel screenshot, and two screenshots in the "Quitting R" section (save-workspace dialog, global options pane) are all dropped, each with an inline footnote explaining the omission — same rationale as the hand-annotated/screenshot figures skipped in Chapters 5, 6 and 8. Added a short Positron-focused aside on two of these footnotes (the Rstudio-session and autocomplete screenshots) noting the modern equivalent, consistent with the precedent set in Chapter 8's Rstudio-specific section.
- **Non-executable illustrative transcripts kept as plain code blocks**: several places in this chapter show R's behaviour when a command is *incomplete* (the `10 +` / `+ 20` continuation prompt, the multi-line `citation(` example, the botched `citblation(` example, and the `q()` / "Save workspace image?" prompt). None of these can be reproduced by a knitr chunk, which always evaluates a complete expression — they're kept as plain fenced code blocks transcribing the book's original console session, following the precedent set for interactive prompts in Chapters 7 and 8.
- **`citation()` output re-executed rather than hand-copied**: R's real `citation()` output today differs cosmetically from the 2013-era text shown in the original (author year, added BibTeX block), so the live chunk uses `trunc-head`/`trunc-tail` tuned to the *current* output's line structure rather than the original's, while preserving the original's two-part (head-and-tail) truncation shape. Likewise `citation` (bare, no parens) uses head-only truncation, matching the original's "just keeps going" framing.
- **Narrow-console wrapping demo made genuinely live**: the original's aside about what `sales.by.month` looks like when the console is very narrow was reproduced by temporarily calling `options(width = 36)` around a real `print()`, rather than hand-editing the vector's output — tuned to 36 characters because that's what reproduces the original's exact `[1]`/`[9]` line break for a 12-element vector. A footnote next to the demo explains the technique.
- **Real inconsistency in the original's worked example, not reproduced**: the original's `sales.by.month * 7` and `profit / days.per.month` outputs both show `0` for May, even though the immediately preceding subsection had just corrected `sales.by.month[5]` to `25`. This looks like a transcription slip in the 2013 text (the printed output wasn't updated after the vector-editing example was added) rather than an intentional example. Since this translation executes the code for real, the live output correctly shows `175`/`~5.65` for May instead; logged in the Issues table below rather than silently matching the original's inconsistent numbers.
- **Cross-references**: forward references to [Pragmatic matters](07-datahandling.qmd) use the real `@sec-datahandling` id (that chapter is already translated), unlike the plain-bracketed-text placeholders used for forward references in Chapters 5, 7 and 8.

## Chapter 4 (R mechanics)

Translated in full (see [04-mechanics.qmd](04-mechanics.qmd)). Notes:

- **Data files**: added `booksales.csv` and `booksales.Rdata` to `data/`. `booksales.Rdata` turns out to be a genuine snapshot of the original author's live R session while writing the book (it contains ~19 variables spanning several different examples, not just book sales figures) rather than a curated example dataset; the chapter's `load()` demonstration calls this out explicitly and then clears the workspace immediately afterward (capturing the names returned invisibly by `load()`) so those variables don't leak into later sections that reuse the same names (`age`, `gender`, `group`, `score`, `expt`) for a fresh, from-scratch demonstration.
- **`Matrix`/`lattice` dependency demo replaced with `car`/`carData`**: the original demonstrates package dependency-loading and detach-protection using `library(Matrix)` (which used to print `Loading required package: lattice`) and a subsequent failed `detach("package:lattice", ...)`. As of the current `Matrix` release, loading it no longer surfaces a dependency message this way. Substituted `car`/`carData` instead, which reproduce both behaviours (a live "Loading required package" message, and a live detach-protection error) exactly, and which the chapter needs anyway for the `car`/`psych` `logit()` masking demo immediately afterward. Logged in the Issues table below since it's a substitution driven by a real change in a dependency's behaviour, not a correction of a book error.
- **`car`/`psych` masking demo kept live**: unlike `Matrix`/`lattice`, the `car ` and `psych` packages still produce the exact "masked" message the original describes (`logit()` is defined in both), so this demonstration runs for real.
- **`group == gender` factor comparison**: R's `Ops.factor` has become stricter since the book was written — comparing two factors whose *level sets* differ now raises a hard error (`level sets of factors are different`) rather than silently comparing the underlying integer codes. This means the original's first `group == gender` example (before labelling levels) already errors today, not just the second one (after labelling) as in the original text. Rewrote the surrounding prose to explain this as a real behaviour change that pre-empts the point the original section builds up to more gradually, and added `error: true` to both live comparisons. Logged in the Issues table below.
- **`print.formula()` no longer directly callable**: same underlying story as the `_bookdown-adaptation`'s note ("Appears to be deprecated") for this example — R's namespace tightening means `print.formula()` (and various other S3 print methods) are no longer exported for direct use, even though method dispatch through `print()` still finds and uses them behind the scenes. The live chunk now shows the resulting `could not find function "print.formula"` error (via `error: true`) and the surrounding prose explains this as illustrating, if accidentally, exactly the point about method dispatch that the section is making. `print.default()` is unaffected and still runs live.
- **`load()` help-file walkthrough**: `help()`/`?` open the Help pane rather than returning text a knitr chunk can capture, so this subsection is presented as a sequence of plain, non-executed transcript blocks rather than live chunks — but the *content* quoted is the real, current output of `?load` (fetched via `tools::Rd2txt(utils:::.getHelpFile(help("load")))`), not hand-copied from the original. The current help page has grown a third `verbose` argument since 2013; the prose was adjusted to describe it alongside `file` and `envir`.
- **Screenshots omitted**: the packages panel, install-packages dialog (×2), update-packages dialog, two Environment-panel views, file panel, and the two CSV-import dialogs are all dropped with inline footnotes, consistent with the precedent in Chapters 3 and 6–8. Several of these footnotes also note the Positron equivalent (Packages pane, Variables pane, Explorer panel, "Import Dataset" workflow) where one exists.
- **`install.packages()` chatter and the commented-out epigraph**: the network-dependent `install.packages("psych")` download transcript is kept as an illustrative, non-executed block (network output can't be faithfully reproduced at render time, matching the precedent for other non-reproducible session transcripts in Chapters 6–8). Separately, the LaTeX source has this chapter's epigraph (a Louis Sullivan quote) commented out (`%\begin{quote}...`), unlike `_bookdown-adaptation` which includes it anyway — followed the LaTeX literally and omitted it, per the Chapter 8 precedent for the same kind of divergence.
- **File-system navigation adapted to this book's own repo**: `getwd()`, `path.expand("~")`, and a `list.files("data")` call are live and reflect this book's own rendering environment rather than the original author's laptop paths; the absolute-path/`setwd()`/Windows-slash illustrations that are inherently OS- and machine-specific are kept as plain, non-executed transcripts (same rationale as the OS-specific examples in Chapters 6 and 8). The absolute-vs-relative-path table is a hand-written Quarto/pandoc table, consistent with the Chapter 3/7 table convention.
- **`save()`/`save.image()` demonstration**: writes to a `tempfile()` rather than a real file in the project directory, so rendering the chapter doesn't leave throwaway `.Rdata` files in the repo; noted inline via footnote. The `who()` example workspace (`data`, `handy`, `junk`) is built for real with matching class/dimensions rather than hand-typed, so the `who()` output is genuine live output.
- **Cross-references**: this chapter both defines several section ids referenced by other chapters (`#sec-mechanics`, `#sec-packageinstall`, `#sec-workspace`, `#sec-navigation`, `#sec-load`, `#sec-useful`, `#sec-factors`, `#sec-dataframes`, `#sec-lists`, `#sec-formulas`, `#sec-generics`, `#sec-help`) and references chapters that are still placeholders ([Pragmatic matters](07-datahandling.qmd) and [Basic programming](08-scripting.qmd) already have real ids and are linked properly; [Study design](02-studydesign.qmd) and [Linear regression](15-regression.qmd) are still placeholders and are linked by title only, per the same follow-up noted for earlier chapters).

## Chapter 1 (Why do we learn statistics?)

Translated in full (see [01-whystats.qmd](01-whystats.qmd)), the last chapter in Part I. Notes:

- **Data files**: added `berkeley.Rdata` (contains `berkeley` and `berkeley.small`) to `data/`, copied from `_original-text/scripts/berkeley.Rdata`.
- **Figure regenerated live**: the Berkeley admissions scatterplot (`fig-berkeley`) is a direct port of `_original-text/scripts/plotberkeley.R` (base R `symbols()`/`lines()`/weighted `lm()`), executed live against `data/berkeley.Rdata` rather than embedding the pre-rendered `.eps`. This chapter's other content is pure prose, tables, and a valid/invalid-argument belief-bias illustration — no other figures to port.
- **Aggregate gender-admission numbers taken from the LaTeX, not the bookdown port**: the LaTeX source states the university-wide male admission rate as 44%; `_bookdown-adaptation/01.01-intro.Rmd` has this as 46%, which looks like a transcription slip on the bookdown side (44% is also consistent with `8442`/`4321` applicants and the department-level breakdown used later in the same section). Followed the LaTeX per the "prefer LaTeX when they disagree" rule in AGENTS.md.
- **Tables**: the four belief-bias 2x2 tables and the two admissions tables are hand-written Quarto/pandoc markdown tables, consistent with the established convention; the two cells intentionally left blank in the original's "valid"/"invalid" breakdown tables (e.g. `argument is valid | 92% ... | ` with no entry when the corresponding condition doesn't apply to that row) are reproduced as blank cells rather than filled in.
- **Cross-references**: `@sec-housingpriceexample` (defined in Chapter 5, already translated) is a real Quarto cross-reference, not a placeholder — this chapter's only forward reference happens to point at an already-translated chapter.
- **Citations**: `Evans1983` and `Bickel1975` were already present in `references.bib` from the Phase 1 bibliography port; `\citeA{}`/`\cite{}` map to narrative `@Key`/bracketed `[@Key]` citations respectively, per the established convention.

## Chapter 9 (Introduction to probability)

Translated in full (see [09-probability.qmd](09-probability.qmd)), the first chapter of Part IV ("Statistical theory") and the first chapter translated after the Chapters 1–8 consistency pass. Notes:

- **No data files or new package dependencies**: this chapter is entirely theoretical/simulation-based (coin flips, dice rolls, and the five core distributions), so nothing was added to `data/` and no new packages were required.
- **`\begin{comment}...\end{comment}` block omitted**: the LaTeX source has a ~170-line derivation of the probability rules in @tbl-probrules (working through $P(\neg A)$, $P(A \cap B)$, $P(A \cup B)$, and $P(B|A)$ using the "pants" example in detail), but it's wrapped in a LaTeX `comment` environment and annotated `%%% THIS SEEMS TOO MUCH` — meaning it was cut from the actual published book and never appeared in the PDF. Left out of the translation for the same reason it's not in the original PDF, not as an editorial cut of our own.
- **Figures**: all 13 figures regenerated as live base-R plots (matching the `col = "blue"`/`frame.plot = FALSE` style already established for single-color emphasis plots in Chapters 5–6), rather than the original's pre-rendered `.eps` files. Multi-panel figures that the original displays side by side (@fig-binomial2, @fig-sdnorm1, @fig-sdnorm2) use `fig-subcap`/`layout-ncol`, following the Chapter 6 precedent; @fig-frequentistprobability and @fig-variaterelations use a single chunk with `par(mfrow = ...)` instead (also a Chapter 6 precedent, for figures the original never breaks up with intervening prose).
- **Tables**: the frequentist coin-flip tally, the "pants" probability distribution, @tbl-probrules, @tbl-distformulas and @tbl-pdistnames are all hand-written Quarto/pandoc markdown tables, consistent with the established convention. The two 10-column coin-flip tallies are kept as two side-by-side-in-source tables (matching the original's own two-table layout), rather than combined into one 20-column table. @tbl-pdistnames follows the LaTeX's (correct) row order rather than the bookdown adaptation's, which has a transcription bug scrambling the "quantile of" row.
- **Citations**: `Fisher1922b` and `Meehl1967` are direct quotations with page numbers, translated as `[@Key, p. N]`; `Evans2000` is a non-narrative citation, translated as `[@Evans2000]`. All three were already present in `references.bib`.
- **Truncated output**: the `print(normal.a)` full-vector printout is truncated with `trunc-head: 3` (head-only, no tail), matching the original's own head-only `BLAH BLAH BLAH` truncation of the same output. The `rbinom(n = 100, ...)` output is *not* truncated, matching the original (which prints it in full).
- **Cross-references**: `@sec-bargraph`, `@sec-datahandling`, `@sec-graphics` and `@sec-continuousdiscrete` are real cross-refs (the last of these is defined in Chapter 2, which already covers continuous-vs-discrete variables — confirmed the id exists before using it). Forward references to *Bayesian statistics*, *The $t$-test*, *Categorical data analysis* and *ANOVA* (Chapters 17, 13, 12 and 14) stay as plain bracketed text, since those chapters are still untranslated placeholders — same convention as the forward-reference entries already logged for Chapters 5, 7 and 8.
- **Part IV introduction not yet translated**: [part-04-statistical-theory.qmd](part-04-statistical-theory.qmd) (from `prelude4.tex`) remains a placeholder; this chapter doesn't depend on it, so it wasn't translated as part of this pass. Still an open follow-up.

## Part IV introduction (Prelude to Part IV)

Translated in full (see [part-04-statistical-theory.qmd](part-04-statistical-theory.qmd)), resolving the follow-up logged in the Chapter 9 notes above. Notes:

- **No data, code, or figures**: like Chapter 2, this is pure prose (a philosophical discussion of the "riddle of induction") plus one epigraph and one extended dialogue — no `load-packages` chunk and no `{{< include _setup.qmd >}}`.
- **Dialogue formatting**: the LaTeX `dialogue`/`\speak{}` environment (used only in this file — `grep`-confirmed no other chapter uses it) has no direct Quarto/pandoc equivalent, so each exchange is rendered as a blockquote with bold **you:**/**me:** speaker labels, one turn per paragraph inside the same blockquote. This is a translation convention invented for this file rather than one carried over from an established precedent.
- **`\PRELUDEHEADER{}` sections** ("On the limits of logical reasoning", "Learning without making assumptions is a myth") became ordinary `##` headings, consistent with how `\section{}` is handled in numbered chapters, even though this page itself is unnumbered.
- **Cross-references**: `Chapter@refch:probability` is a real `@sec-probability` cross-ref now that Chapter 9 is translated; `Chapter@refch:estimation` and `Chapter@refch:hypothesistesting` (Chapters 10–11) stay as plain bracketed text (`[Estimation]`, `[Hypothesis testing]`), since those chapters are still untranslated placeholders — same convention as forward references elsewhere.
- **Footnote**: the single `\FOOTNOTE{}` (sourcing the Wellington quote to a Bartleby URL) became a standard `^[...]` margin note with the URL as a Markdown autolink.

## Chapters 1–8: proofreading pass for consistency

Audited all eight translated chapters together for structural/presentational
consistency (as opposed to content correctness, which stays in Phase 4).
Checked: chapter/section heading levels and ids, `{{< include _setup.qmd >}}`
and `load-packages` chunk placement, footnote syntax, key-term bold-italic
markup (`**_term_**`), `data/*.Rdata` load paths, `fig-`/`tbl-` chunk-label
and caption conventions, "Rstudio" spelling, citation style, and the
`BLAH BLAH BLAH`/`trunc-head`/`trunc-tail` truncation convention. All of
these turned out to be consistent already, with one exception:

- **Fixed**: Chapter 5's mid-chapter "Epilogue" epigraph (the Stalin/Ellman
  quotes) used `--` (en dash) for its attribution lines, while every other
  epigraph attribution in the book (Chapters 1, 2, 3, 6, 7, 8) uses `---`
  (em dash). The original LaTeX actually uses a plain `--` for *all*
  attributions, chapter-opening or not — so this is a case where the
  Quarto translation itself introduced the `---` convention and simply
  missed applying it consistently to this one in-chapter epigraph. Changed
  to `---` to match. Left the *numeric range* `950,000 -- 1,200,000` alone,
  since that's a genuine en dash for a range, not an attribution.
- Confirmed via `quarto render` (whole book, no warnings/errors) that no
  citations are broken, no duplicate chunk labels exist across chapters,
  and the newly-cleaned-up `@sec-` cross-refs (previous pass) all still
  resolve correctly.
- "data set" vs "dataset" spelling is inconsistent within some chapters
  (e.g., Chapter 5 uses both), but this mirrors the same inconsistency
  already present in the original LaTeX in roughly the same proportions,
  so it was left alone per the faithfulness-first rule rather than
  "fixed" as a translation issue.

## Chapters 9–12: proofreading pass for consistency

Audited Chapters 9–12 together for structural/presentational consistency, mirroring the
[Chapters 1–8 audit](#chapters-18-proofreading-pass-for-consistency) above (content
correctness stays in Phase 4). Checked: `load-packages`/`{{< include _setup.qmd >}}`
placement and chunk options, chapter/section heading levels and `#sec-` ids, footnote
syntax, key-term bold-italic markup (`**_term_**`), `data/*.Rdata` load paths, `fig-`/`tbl-`
chunk-label and caption conventions, epigraph attribution formatting (`---` em dash),
citation style, leftover LaTeX escapes/macros, "Rstudio" spelling, and the `BLAH BLAH
BLAH`/`trunc-head`/`trunc-tail` truncation convention. One inconsistency found and fixed;
everything else checked out:

- **Fixed**: Chapter 12's `load-packages` chunk was placed *after*
  `{{< include _setup.qmd >}}` (reversed relative to the established order) and used
  `#| message: false` rather than `#| include: false`, so the chunk itself would have
  stayed visible in the rendered chapter (silencing only the package-startup message)
  instead of being hidden entirely like every other chapter's `load-packages` chunk
  (Chapters 5–8, 10). Reordered to put the hidden `load-packages` chunk first and switched
  to `#| include: false`, matching the Chapters 5–8/10 convention. The chapter's second,
  deliberately *visible* `library(lsr)` call partway through "The cards data" (reproducing
  the original's own pedagogical `library(lsr)` line) was left alone — this duplicate
  hidden-then-visible pattern already has precedent in Chapters 5 and 10.
- Confirmed Chapters 9 and 11 correctly have *no* `load-packages` chunk at all, since
  neither chapter's live code calls any package function — consistent with the
  no-chunk-when-nothing's-used convention already established for Chapter 2.
- Verified no stray LaTeX leftovers (`\cite`, `\section`, `\chapter`, `\item`,
  `\filename`, `Section@ref`/`Chapter@ref`, etc.) survived translation in any of the four
  chapters.
- Verified `##`-level section headings all carry a `#sec-` id (no bare or non-`sec`-prefixed
  ids), while `###`-level subsections carry ids only where something actually
  cross-references them — consistent with the pattern already established in Chapters 1–8.
- Verified epigraph attributions consistently use `---` (em dash) across all four chapters
  (`John Locke`, `Ludwig Wittgenstein`, `Attributed to G. O. Ashley`, `George Box`,
  `H.G. Wells`, `Futurama`), with `Unknown origin` used for the one epigraph the original
  itself says is unsourced (Chapter 10's "never having to say you're certain" quote).
- Verified every citation key used in Chapters 9–12 already exists in `references.bib`, and
  that `quarto render` produces zero unresolved-citation or unresolved-cross-reference
  warnings across the whole book.
- "data set" spelling is used consistently (no "dataset") across all four chapters, mirroring
  the original LaTeX's own usage in this stretch of the book — left alone per the
  faithfulness-first rule, same rationale as the Chapters 1–8 audit's "data set" finding.
- No "Rstudio" mentions in Chapters 9–12 (none of these chapters discuss the IDE), so there
  was nothing to check against the Positron-footnote convention established in Chapters 3–4
  and 8.
- Confirmed via `quarto render` (whole book, no warnings/errors) after the fix that nothing
  else regressed.

## Chapter 2 (Study design)

Translated in full (see [02-studydesign.qmd](02-studydesign.qmd)). Notes:

- **No code, data, or figures**: unlike every chapter translated so far, this one is pure prose plus two small conceptual tables — no `load-packages` chunk, no `{{< include _setup.qmd >}}`, and no executable R at all. This matches the bookdown adaptation's treatment (its two `knitr::kable()` tables are `echo=FALSE` and purely presentational).
- **Tables**: both of the original's tables (`tab:scalescont` — scales of measurement × continuous/discrete, and `tab:ivdv` — IV/DV vs. predictor/outcome terminology) are hand-written Quarto/pandoc markdown tables with `{#tbl-...}` ids, consistent with the Chapter 7 table convention. The tick marks in `tab:scalescont` use a literal ✓ character rather than LaTeX's `\checkmark`, since there's no math-mode requirement here.
- **Citations**: all citation keys used in this chapter (`Campbell1963`, `Stevens1946`, `Kahneman1973`, `Pfungst1911`, `Hothersall2004`, `Rosenthal1966`, `Adair1984`, `Ioannidis2005`, `Kuhberger2014`) were already present in `references.bib` from the Phase 1 bibliography port, so no additions were needed. `\citeA{}` (author-prominent) became bare `@Key` narrative citations; `\cite{}` became `[@Key]`; `\cite<see>[for discussion]{}` became `[see @Key for discussion]` — following the precedent already established in Chapters 3–8.
- **Section id added for an unlabelled section**: the original's "Confounds, artifacts and other threats to validity" `\section` has no `\label` in the LaTeX (unlike every other section in the chapter), so it had no natural cross-ref target. Added `{#sec-confounds}` for consistency with the rest of the chapter's section ids, even though nothing in the original or this translation currently links to it.
- **Cross-references**: this is the first chapter to be translated with no forward references at all to still-untranslated chapters — its only cross-references are internal (to its own sections/tables via `@sec-`/`@tbl-`), so there's nothing to log as a placeholder-bracketed-text follow-up here.

## Chapter 10 (Estimation)

Translated in full (see [10-estimation.qmd](10-estimation.qmd)), the second chapter of Part IV. Notes:

- **Data files**: added `afl24.Rdata` (contains the `afl` data frame with 1987–2010 match records) to `data/`, needed for the confidence-interval-plotting section.
- **New package dependencies**: `sciplot` (for `bargraph.CI()`/`lineplot.CI()`) and `gplots` (for `plotmeans()`) weren't previously needed. Installed both locally via `pak::pak()` and added to the CI workflow's package list, alongside `lsr`/`psych`/`car`.
- **Chip-bag diagrams omitted**: the three simple-random-sampling illustrations (`srs1`, `brs`, `srs2` — a bag of black/white chips being drawn with/without replacement, and a biased draw) are hand-drawn diagrams with no generating R script anywhere in `_original-text/scripts/`, unlike almost every other figure in this book. Each is replaced with a footnote at first mention explaining the omission, following the same rationale as the hand-annotated/screenshot figures skipped in Chapters 3, 5, 6 and 8 — the surrounding prose already describes the scenario in words.
- **Random demonstrations made genuinely live, with prose adjusted to match**: unlike the fixed real-world data used in Chapters 5–9, this chapter is built almost entirely around repeated `rnorm()`/`rbeta()` simulations (IQ samples, sampling distributions, the CLT demo, estimator bias, confidence-interval replications). Rather than hardcode the original's specific simulated values (e.g. "the mean IQ in this sample turns out to be exactly 95"), every such claim is now backed by an inline `` `r ...` `` expression referencing a live-computed object, so the numbers quoted in prose always match the actual simulation run at render time — consistent with the precedent set for `weekdays(Sys.Date())` in Chapter 8. No `set.seed()` is used anywhere in the book (checked: none of Chapters 1–9 use it either), so these specific numbers will differ from both the original book and from one render of this book to the next; this is an inherent, expected consequence of live execution rather than an error, and isn't logged in the Issues table below for that reason (matching how Chapter 9's `rbinom()`/`rnorm()` demonstrations are treated).
- **`print(IQ)` truncation**: the $N=10{,}000$ IQ vector's hand-truncated printout (4 head lines / 3 tail lines around a `BLAH BLAH BLAH` marker) uses `trunc-head: 4`/`trunc-tail: 3`, following the Phase 2 convention. Line-wrapping will vary slightly from the original's exact 17-values-per-line layout depending on the live-generated values' digit widths, but the truncation *shape* (a few head lines, a few tail lines, `BLAH BLAH BLAH` in between) is faithfully reproduced.
- **`fig:IQdist` split from the original's single three-panel figure into two figures**: the original combines the IQ population curve, an $N=100$ sample histogram, and an $N=10{,}000$ sample histogram into one figure (`fig:IQdist`), referenced first in "Population parameters and sample statistics" and again later in "The law of large numbers" (where the $N=10{,}000$ generating code is shown explicitly). The translation keeps all three panels in a single `fig-IQdist` (population, $N=100$, $N=10{,}000$) generated together where the original first introduces it, then reuses the same object (`IQ`) for the truncated `print()`/`mean()`/`sd()` demonstration in the Law of Large Numbers section without regenerating a fresh sample — a minor simplification versus the original's implied two-figure-reference structure, but keeps the panel-c histogram and the explicitly-shown generating code perfectly in sync.
- **"Ten replications" table made live**: @tbl-replications (10 replications of a $N=5$ IQ experiment) is genuinely simulated and rendered via `knitr::kable()` with a `tbl-cap`/`label` chunk option, rather than the hand-written Quarto/pandoc markdown table used for every other (static) table in this book so far. This is a deliberate one-off exception to the hand-written-table convention noted in Chapters 1–9: because the table's contents are randomly generated at render time, a hand-typed table would either not match the live code or would have to fake being "live" — using `kable()` keeps the table and the code that produces it genuinely in sync.
- **Sampling-distribution figures re-derived from first principles rather than the original's shortcut code**: `_original-text/scripts/estimationImages.R` and the (partially commented-out) `extraSamplingDists.R` generate several sampling-distribution histograms (`samplingDist1/2/3`, `samplingDistMean`/`samplingDistMax`) using a mathematical shortcut — e.g. drawing directly from $\mathcal{N}(\mu, \sigma/\sqrt{N})$ rather than literally averaging $N$ draws — since the two are mathematically equivalent for the mean. The translation instead uses genuine Monte Carlo simulation (`replicate(10000, mean(rnorm(N, ...)))`) throughout @fig-sampdistmean, @fig-sampdistmax and @fig-IQsamp, matching what the surrounding prose actually describes ("replicating this experiment over and over again") rather than the scripts' faster-but-opaque approximation. @fig-cltdemo and @fig-estimatorbias, by contrast, port the original scripts' matrix-based approach directly, since those already simulate genuinely (drawing $n \times N$ observations and averaging/computing sd across rows).
- **@fig-sampdistsd and @fig-cirep ported from `extraSamplingDists.R` and `confidenceIntervals.R`**: the sample-standard-deviation sampling distribution (dividing by $N$, i.e. the biased $s$, not $\hat\sigma$) and the two confidence-interval-replication panels (@fig-cirep, $N=10$ and $N=25$) both had usable source scripts (the former partly commented out, the latter only implementing the $N=25$ case) — both were reproduced live and adapted for both sample sizes as needed. The original's throwaway claim that "exactly 95 of them contained the true mean" is replaced with a live-computed count of misses (`n.missed`), reported inline rather than hardcoded, for the same live-execution reason described above.
- **CI-plotting section faithfully includes all three original functions**: unlike `_bookdown-adaptation` (which drops `plotmeans()` and only demonstrates `bargraph.CI()`/`lineplot.CI()`), the translation keeps all three of the original's approaches (`bargraph.CI()`, `lineplot.CI()`, `plotmeans()`), each producing its own live figure, per the faithfulness-first rule — all three ran without issue against the current `sciplot`/`gplots` releases.
- **Citations**: `Stigler1986` and `Keynes1923` (both already present in `references.bib` from the Phase 1 bibliography port) are translated as blockquotes with a bracketed citation immediately after the quoted text (`[see @Stigler1986, p. 65]`, `[@Keynes1923, p. 80]`), matching the original's `\begin{quote}...\cite{}...\end{quote}` structure — a slightly different pattern from the epigraph-style em-dash attribution used for chapter-opening quotes elsewhere in the book, since these are in-text quotes rather than epigraphs. The "Statistics means never having to say you're certain" epigraph at the start of @sec-ci has no citation key (the original itself says "I've never found the original source"), so it's kept as an attributed-to-"Unknown origin" blockquote with a footnote, following the standard epigraph convention.
- **Cross-references**: this chapter defines `#sec-estimation`, `#sec-srs`, `#sec-pop`, `#sec-lawlargenumbers`, `#sec-samplesandclt`, `#sec-samplingdists`, `#sec-clt`, `#sec-pointestimates`, `#sec-ci` and `#sec-ciplots`. References to already-translated chapters/sections (`@sec-descriptives`, `@sec-normal`, `@sec-probability`, `@sec-studydesign`, `@sec-probmeaning`, `@sec-measurement`, `@sec-var`, `@sec-packageinstall`) are real Quarto cross-refs; forward references to *Linear regression* and *Bayesian statistics* (Chapters 15 and 17, still untranslated placeholders) stay as plain bracketed text, per the established convention. The link to the [prelude to Part IV](part-04-statistical-theory.qmd) uses a plain Markdown file link rather than a `@sec-` cross-ref, since that page is an unnumbered part-introduction with no section id of its own.

## Chapter 11 (Hypothesis testing)

Translated in full (see [11-hypothesistesting.qmd](11-hypothesistesting.qmd)), the third chapter of Part IV. Notes:

- **No data files; no new package dependencies**: this chapter is entirely built around one running example (the ESP/binomial-test scenario), computed live with base R (`dbinom()`, `pbinom()`, `qbinom()`, `binom.test()`). The `lsr` package is mentioned in a footnote (as the source of effect-size functions used *later* in the book) but no code in this chapter actually calls it, so no `load-packages` chunk was added — consistent with the precedent set by Chapter 2 (no chunk when nothing is actually used) rather than Chapters 9–10 (which do call `lsr`-adjacent packages).
- **Figures**: all 7 figures (`samplingDist`, `rejectionRegion1-4`, `powerTheta`, `powerN`) are ported directly from `_original-text/scripts/nhstImages.R`'s base-R plotting code (custom `setUpPlot()`/`addDistPlot()`/`addArrow()` helpers inlined into each chunk rather than kept as reusable functions, since each figure is only built once), using `col = "blue"` in place of the script's `emphCol <- rgb(0,0,1)` — consistent with the plain `"blue"` convention already used for single-color emphasis plots in Chapters 5, 6 and 9. `@fig-crit3`/`@fig-crit4` (the $\theta=.55$/$\theta=.70$ alternative-hypothesis sampling distributions) are kept as two separate figures rather than combined with `fig-subcap`, since the original's prose discusses them sequentially with substantive text in between, matching the Chapter 6 precedent for panels introduced across separate paragraphs.
- **Tables**: the two decision-matrix tables (plain, then annotated with $\alpha$/$\beta$), the "Dan's research/statistical hypothesis" table, the $\alpha$-vs-reject table, @tbl-pvaltable (significance-stars convention) and @tbl-effectsizeguide are all hand-written Quarto/pandoc markdown tables, consistent with the established convention.
- **Epigraph with no bibliography entry**: the chapter-opening Wittgenstein quote (*Tractatus Logico-Philosophicus*, 1922) and the "G. O. Ashley" quote on statistical jargon have no corresponding `references.bib` entries — the original itself only cites Wittgenstein by name/year in prose (no `\cite`) and explicitly says the Ashley attribution is unsourced. Both are kept as plain attributed blockquotes with an explanatory footnote, rather than invented `@Key` citations.
- **Citations**: `Box1976`, `Cohen1988`, `Ellis2010`, `Lehmann2011` and `Gelman2006` were already present in `references.bib` from the Phase 1 bibliography port. `\citeyear[p.~792]{Box1976}` became `[@Box1976, p. 792]` after the "George Box" attribution, matching the blockquote-plus-bracketed-citation pattern established in Chapter 10 for `Stigler1986`/`Keynes1923`. `\cite<e.g.,>{Cohen1988,Ellis2010}` became `[e.g., @Cohen1988; @Ellis2010]`; `\cite<see>[for a historical summary]{Lehmann2011}` and `\cite<see>{Gelman2006}` became `[see @Lehmann2011 for a historical summary]` and `[see @Gelman2006]`.
- **Cross-references**: `@sec-samplingdists` (Chapter 10) and `@sec-binomial`/`@sec-probability` (Chapter 9) are real cross-refs, confirmed to exist before use. Forward references to *Categorical data analysis* and *Bayesian statistics* (Chapters 12 and 17, still untranslated placeholders) stay as plain bracketed text, per the established convention for forward references to untranslated chapters.
- **`binom.test()` output re-executed rather than hand-copied**: the live chunk's output matches the original's numbers exactly (successes = 62, p-value = 0.02098, 95% CI 0.5174607–0.7152325) — verified after rendering, so no `trunc-head`/`trunc-tail` or content adjustment was needed here, unlike some base-R functions in earlier chapters whose output has drifted since 2013.

## Chapter 12 (Categorical data analysis)

Translated in full (see [12-chisquare.qmd](12-chisquare.qmd)), the first chapter of Part V ("Statistical tools"). Notes:

- **Data files**: added `randomness.Rdata` (`cards`), `chapek9.Rdata` (`chapek9`), `salem.Rdata` (`trial`) and `agpp.Rdata` (`agpp`) to `data/`.
- **No new package dependencies**: everything in this chapter uses `lsr` (already pinned) plus base R (`chisq.test()`, `fisher.test()`, `mcnemar.test()`).
- **Every numeric result reproduces exactly**: unlike several of the probability/estimation chapters, this chapter's examples all use fixed, real data sets (no `rnorm()`/`rbinom()`-style live simulation), and every test statistic, $p$-value and effect size verified against the original text character-for-character before translating — `goodnessOfFitTest()`, `associationTest()`, `cramersV()`, `chisq.test()` (with and without Yates' correction), `fisher.test()` and `mcnemar.test()` all reproduce the book's numbers exactly, including the deliberately-uncorrected $G$-test aside (`G = 8.65`, `p = .034`) in the "comment on statistical notation" section. No presentational accommodations were needed for numeric drift, a first for a chapter this size.
- **Figures**: both figures (`fig-manychi`, the three-df chi-square density comparison, and `fig-goftest`, the rejection-region illustration for the cards GOF test) are ported directly from `_original-text/scripts/chisquareImages.R`'s base-R plotting code, using `col = "blue"` for the density curves/legend in `fig-manychi` (consistent with the single-color-emphasis convention from Chapters 5, 6, 9 and 11) and a black density curve with a blue hatched rejection-region polygon in `fig-goftest`, matching the original script's use of a black curve against a blue-shaded critical region.
- **Tables**: the label/index/math-symbol/R-command notation table, the two "with row/column totals" contingency-table layouts (Chapek 9, Fisher/Salem, McNemar/AGPP with algebraic $a,b,c,d$ labels) are all hand-written Quarto/pandoc markdown tables, consistent with the established convention.
- **Epigraphs**: the *Futurama* dialogue epigraph (chi-square test of independence section) is formatted as a blockquote with one line per turn, following the dialogue-formatting precedent set for [the Part IV introduction](part-04-statistical-theory.qmd) rather than inventing a new convention. The H.G. Wells "comment on statistical notation" epigraph has no bibliography entry (same as the unsourced Ashley quote in Chapter 11), so it's kept as a plain attributed blockquote.
- **Citations**: `Pearson1900`, `Fisher1922`, `Hogg2005`, `Sokal1994`, `Yates1934`, `Cramer1946`, `Cochran1954`, `Larntz1978`, `McNemar1947`, `Agresti1996` and `Agresti2002` were all already present in `references.bib` from the Phase 1 bibliography port; no additions were needed.
- **Cross-references**: this chapter defines `#sec-chisquare`, `#sec-goftest`, `#sec-goftestinr`, `#sec-chisqreport`, `#sec-chisqindependence`, `#sec-assoctestinr`, `#sec-yates`, `#sec-chisqeffectsize`, `#sec-chisqassumptions`, `#sec-chisqtest`, `#sec-fisherexacttest` and `#sec-mcnemar`. References to already-translated chapters/sections (`@sec-binomial`, `@sec-clt`, `@sec-otherdists`, `@sec-freqtables`, `@sec-effectsize`) are real cross-refs. Forward references to *The $t$-test*, *ANOVA* and *Linear regression* (Chapters 13–15, still untranslated placeholders) stay as plain bracketed text, per the established convention. Also **resolved** Chapter 11's two forward references to this chapter (a prose cross-ref and a footnote), converting `[Categorical data analysis]` to `@sec-chisqreport`/`@sec-chisqindependence` now that this chapter has real section ids — logged in the Issues table below for visibility even though it's a trivial follow-through, not a correction.
- **Continuity-correction quote reproduced live via a real warning**: the Salem `chisq.test()` example is shown with `warning: true` so that R's genuine `"Chi-squared approximation may be incorrect"` warning renders inline, rather than being paraphrased — matches the original's own framing ("R gives me a warning message").

## Chapter 13 (The $t$-test)

Translated in full (see [13-ttest.qmd](13-ttest.qmd)), the second chapter of Part V and one of the largest chapters translated so far. Notes:

- **Data files**: added `zeppo.Rdata` (`grades`), `harpo.Rdata` (`harpo`), `chico.Rdata` (`chico`), `awesome.Rdata` (`awesome`), `awesome2.Rdata` (`score.A`/`score.B`) and `happy.Rdata` (`happiness`) to `data/`.
- **No new package dependencies**: this chapter is the first to actually call `psych::describe()` and `gplots::plotmeans()` live in a chunk (both already installed/CI-pinned since Chapters 5 and 10 respectively, but not previously exercised together in one chapter); no additions were needed to the CI workflow's package list.
- **Every numeric result reproduces exactly**: verified live against the original before translating — `oneSampleTTest()`, `independentSamplesTTest()` (Student and Welch), `pairedSamplesTTest()` (wide and long form), `cohensD()` (all four `method`s used in the chapter), `t.test()`, `wilcox.test()` and the manual $z$-test/`pnorm()` walkthrough all reproduce the book's numbers exactly (e.g. $t(19)=2.255$, $t(31)=2.115$/$2.034$, $t(19)=6.475$, $d=0.504$/$0.740$/$0.724$/$1.448$/$0.216$), including the deliberately-non-significant Welch result ($p=.054$) that the original's prose builds an entire discussion around.
- **Figures**: 13 of the chapter's figures are ported as live base-R plots. Most come directly from `_original-text/scripts/ttestImages.R` (`oneSampleHyp()` → @fig-ztesthyp/@fig-ttesthyp-onesample, `indepTTestHyp()` → @fig-ttesthyp/@fig-ttesthyp2, `histograms()` → @fig-zeppo/@fig-harpohist, `pairedFigs()` → @fig-pairedt, `qqPlots()` → @fig-qq1/@fig-qq2, `zTestRegions()` → @fig-ztest), each refactored from the script's per-call anonymous plotting code into small reusable local functions (`plot_one_sample_hyp()`, `plot_indep_hyp()`, `plotHist()`) since each is called twice within the chapter (once per hypothesis/dataset) rather than once per script run. Three figures had **no** generating script anywhere in `_original-text/scripts/` (@fig-ttestdist, the $t$-vs-normal density comparison; @fig-ttestci, the Anastasia/Bernadette means-with-CI plot; @fig-swdist, the Shapiro-Wilk $W$ sampling-distribution comparison) — these were built from scratch: @fig-ttestdist and @fig-ttestci as direct, deterministic plots (`dt()`/`dnorm()` overlay; `gplots::plotmeans()` on the real `harpo` data), and @fig-swdist via genuine Monte Carlo simulation (2000 replicates of `shapiro.test()$statistic` for $N=10,20,50$ samples from a standard normal), consistent with the live-simulation precedent set for sampling-distribution figures in Chapter 10.
- **Tables**: the critical-$z$-value table and the Cohen's $d$ interpretation table are hand-written Quarto/pandoc markdown tables, consistent with the established convention. The plain summary table of Anastasia's/Bernadette's descriptive statistics (mean/std dev/N) is also hand-written, matching the original's own non-executed summary table (the original explicitly says "Rather than show the R output, here's a nice little summary table").
- **Citations**: `Student1908`, `Box1987`, `Welch1947`, `Cohen1988`, `McGrath2006`, `Hedges1981`, `Hedges1985` and `Shapiro1965` were all already present in `references.bib` from the Phase 1 bibliography port; no additions were needed.
- **Cross-references**: this chapter defines `#sec-ttest`, `#sec-zassumptions`, `#sec-onesamplettest`, `#sec-ttestoneassumptions`, `#sec-studentttest`, `#sec-studentassumptions`, `#sec-welchttest`, `#sec-pairedsamplesttest`, `#sec-ttestfunction`, `#sec-cohensd`, `#sec-shapiro` and `#sec-wilcox`. References to already-translated chapters/sections (`@sec-normal`, `@sec-clt`, `@sec-zscore`, `@sec-otherdists`, `@sec-onesidedtests`, `@sec-mcnemar`, `@sec-probability`, plus file links into [Categorical data analysis](12-chisquare.qmd), [Estimating unknown quantities from a sample](10-estimation.qmd), [Hypothesis testing](11-hypothesistesting.qmd), [Descriptive statistics](05-descriptives.qmd) and the `#sec-reshape`/`#sec-sortframe` ids in [Pragmatic matters](07-datahandling.qmd)) are real cross-refs, confirmed to exist before use. Forward references to *ANOVA* (Levene's test, and the "more correct notation" for the pooled-variance sum) and *Linear regression* (multiple predictors) stay as plain bracketed text, since those chapters (14, 15) are still untranslated placeholders — same convention as forward references elsewhere.
- **Multi-panel figure captioning**: @fig-pairedt (means-with-CI, scatterplot, improvement histogram) uses `fig-subcap`/`layout-ncol: 3` following the established multi-panel convention; cross-references to its individual panels use Quarto's `@fig-pairedt-1`/`-2`/`-3` subfigure-numbering syntax rather than lettered panels, since Quarto doesn't support the original's "panel a/b/c" labelling directly.

## Chapter 14 (Comparing several means / one-way ANOVA)

Translated in full (see [14-anova.qmd](14-anova.qmd)), the third chapter of Part V. Notes:

- **Data files**: `clinicaltrial.Rdata` (`clin.trial`) was already present in `data/` (added in an earlier pass alongside other Part V data); no new files needed.
- **No new package dependencies**: `lsr` (`etaSquared()`, `posthocPairwiseT()`), `gplots` (`plotmeans()`) and `car` (`leveneTest()`) were all already installed/CI-pinned from Chapters 5, 10 and 4 respectively.
- **Every numeric result reproduces exactly**: verified live against the original before translating — the hand-calculated $\mbox{SS}_w=1.39$/$\mbox{SS}_b=3.45$/$F(2,15)=18.6$/$p=8.65\times10^{-5}$ walkthrough, `etaSquared()` ($\eta^2=.713$), `pairwise.t.test()`/`posthocPairwiseT()` under all three correction methods, `leveneTest()` (both `center` settings), `shapiro.test()` ($W=.96$, $p=.61$), `oneway.test()` (Welch and equal-variance), `kruskal.test()` ($K=12.076$), and the closing ANOVA/$t$-test equivalence demonstration (`therapy` as predictor) all reproduce the book's numbers exactly. No presentational accommodations were needed for numeric drift, consistent with Chapter 12's experience and unlike some of the earlier, simulation-heavy chapters.
- **Two LaTeX bracket typos fixed to render**: the original has `$Q=(\sum_{k=1]^G N_k \alpha_k^2)/(G-1)$` and `$1 + \frac{2]{df_2 - 2}$` (a stray `]` where a `}` belongs, in two different footnotes near @sec-anovamodel). Both are clear transcription slips rather than content errors, but an unmatched brace/bracket risks broken math rendering rather than just looking wrong, so — unlike ordinary wording/statistical errors — these were corrected to `$Q=(\sum_{k=1}^G N_k \alpha_k^2)/(G-1)$` and `$1 + \frac{2}{df_2 - 2}$` to render correctly. Logged in the Issues table below alongside the similar `aggregate()`/base-R-signature-change entries from earlier chapters, since both are "had to fix it to make it work" cases rather than silent content corrections.
- **Figures**: `fig-moodgain` (the `plotmeans()` mood-gain-by-drug plot) is straightforwardly live. `fig-anovavar` (between-group/within-group variation, two panels) and `fig-normalityanova` (residual histogram/QQ plot, two panels) are ported directly from `_original-text/scripts/anovaImages.R`'s base-R plotting code, using `fig-subcap`/`layout-ncol: 2` for both pairs, consistent with the Chapter 6/9/13 multi-panel convention for figures the original displays side by side. The between/within figure keeps the script's plain `gray20` colour scheme (no blue emphasis colour), matching the original — this pair of figures illustrates a general concept rather than emphasising one specific quantity, unlike the single-colour-emphasis convention used elsewhere.
- **Tables**: the notation example (cool/uncool people), the ANOVA table template (@tbl-anovatable), the worked-example pedagogical tables (built up incrementally across several steps, matching the original's own incremental construction), the eight-"states-of-the-world" table (✓ marks following the Chapter 2 convention rather than LaTeX's `\checkmark`), and the Holm-correction worked example are all hand-written Quarto/pandoc markdown tables, consistent with the established convention.
- **Bare `\item` lists converted to bullet lists**: several places in the original use standalone `\item` commands without an enclosing `itemize`/`enumerate` environment (the three null-hypothesis propositions, the normality/homogeneity/independence assumption list, the `oneway.test()` argument list, and the closing summary list) — all converted to ordinary Markdown bullet lists.
- **Citations**: `Hays1994`, `Shaffer1995`, `Hsu1996`, `Dunn1961`, `Holm1979`, `Levene1960`, `BrownForsythe1974`, `Welch1951` (distinct from Chapter 13's `Welch1947`, which covers the Welch $t$-test rather than the Welch one-way ANOVA), `KruskalWallis1952` and `Sahai2000` were all already present in `references.bib` from the Phase 1 bibliography port; no additions were needed. The chapter-opening epigraph has no citation key in the original (unsourced), consistent with several other chapters' unsourced epigraphs.
- **Advanced/optional subsection**: "The model for the data and the meaning of $F$" (`\advanced{}` in the original, @sec-anovamodel) is flagged with a `callout-note` rather than any special LaTeX-specific styling, since Quarto has no direct equivalent of the original's `\advanced{}` macro — this is a new convention for this book, logged here since it may recur in later chapters that use the same LaTeX macro.
- **Cross-references**: this chapter defines `#sec-anova`, `#sec-anxifree`, `#sec-anovaintro`, `#sec-anovamodel`, `#sec-anovacalc`, `#sec-introduceaov`, `#sec-aovobjects`, `#sec-etasquared`, `#sec-posthoc`, `#sec-anovaassumptions`, `#sec-levene`, `#sec-welchoneway`, `#sec-anovanormality`, `#sec-kruskalwallis` and `#sec-anovaandt`. References to already-translated chapters/sections (`@sec-var`, `@sec-probability`, `@sec-otherdists`, `@sec-estimation`, `@sec-hypothesistesting`, `@sec-datahandling`, `@sec-shapiro`, `@sec-graphics`, plus file links into [The $t$-test](13-ttest.qmd)) are real cross-refs, confirmed to exist before use. Forward references to *Factorial ANOVA* and *Linear regression* (Chapters 16 and 15, still untranslated placeholders) stay as plain bracketed text, per the established convention — this includes the `posthoc2`/`plannedcomparisons` sections and the `interactions` section, all of which live in Chapter 16.

## Chapter 15 (Linear regression)

Translated in full (see [15-regression.qmd](15-regression.qmd)), the fourth chapter of Part V. Notes:

- **No new data files**: `parenthood.Rdata` (`dan.sleep`, `baby.sleep`, `dan.grump`, `day`) was already present in `data/` from Chapter 5.
- **New package dependencies**: `lmtest` (for `coeftest()`) turned out to already be installed as a transitive dependency in this session, but was added explicitly to the CI workflow's package list since no earlier chapter actually calls it. `scatterplot3d` (for @fig-multipleregression) is a genuinely new dependency, installed via `pak::pak()` and added to CI, consistent with the `pak`-over-`install.packages()` precedent from Chapter 5.
- **Every numeric result reproduces exactly**: verified live against the original before translating — `lm()`/`summary()` coefficients and $t$/$F$ statistics for `regression.1` and `regression.2`, $R^2$/adjusted $R^2$, `confint()`, `standardCoefs()`, `cor.test()`, `correlate(test = TRUE)`, `cooks.distance()` (day 64), `shapiro.test()`, `ncvTest()`, `coeftest(vcov = hccm)`, `vif()` (both models), `residualPlots()`'s curvature tests, and the full `step()` backward/forward traces, `AIC(M0, M1)` and `anova(M0, M1)` all reproduce the book's numbers exactly. This is now the fourth Part V chapter in a row (after 12–14) with no numeric drift requiring a presentational accommodation.
- **Figures with no generating script, built from scratch**: `_original-text/scripts/regressionImages.R` only implements the four introductory scatterplot/SSE figures (@fig-regression0, @fig-regression1, @fig-regression3) — everything from @fig-multipleregression onward has no script anywhere in `_original-text/scripts/` or a usable equivalent in `_bookdown-adaptation` (which just embeds the original's pre-rendered static images via `knitr::include_graphics()`). Handled case by case:
  - @fig-multipleregression (the 3D `dan.sleep`/`baby.sleep`/`dan.grump` scatterplot with a fitted regression plane) is regenerated live using the `scatterplot3d` package (`scatterplot3d()` + `plane3d()`), a static-device alternative to the original's `car::scatter3d()` (which relies on `rgl`/OpenGL and doesn't work headlessly on this book's Linux CI).
  - @fig-outlier, @fig-leverage and @fig-influence (the three anomalous-data concept diagrams) are hand-drawn illustrations in the original with no generating script at all. Rebuilt from a small simulated data set (fixed `set.seed()`, since these are illustrative diagrams rather than live-computed claims quoted in prose — unlike the sampling-distribution simulations in Chapter 10) constructed so each of the three anomaly types (outlier: unusual $Y$, typical $X$; leverage: unusual $X$, consistent with the trend; influence: unusual $X$, typical $Y$ but inconsistent with the trend) is unambiguous, with a dashed line showing the fit excluding the anomalous point and a solid blue line showing the fit including it. A footnote at first mention explains the substitution, consistent with the rationale given for other hand-drawn/screenshot figures skipped or reconstructed in earlier chapters.
  - @fig-regressionplot1 through @fig-regressionplot5 (the standard `plot.lm()` diagnostic panels), @fig-residhist, @fig-regressionlinearity and @fig-residualPlots (`car::residualPlots()`) needed no bespoke script at all — they're one-line calls on the already-fitted `regression.2` object, so they're just live chunks like everything else in the chapter.
- **Tables**: the `lm()`/`confint()` argument-list bullets (originally bare `\item`s with no enclosing `itemize`) are converted to ordinary Markdown bullet lists, consistent with the Chapter 14/15-precursor convention for the same LaTeX pattern (e.g. Chapter 15's own assumptions-of-regression list).
- **Citations**: `Fox2011`, `Akaike1974`, `Cook1983`, `White1980` and `Long2000` were all already present in `references.bib` from the Phase 1 bibliography port; no additions were needed.
- **Cross-references**: this chapter defines `#sec-regression`, `#sec-introregression`, `#sec-regressionestimation`, `#sec-lm`, `#sec-multipleregression`, `#sec-r2`, `#sec-regressiontests`, `#sec-regressionsummary`, `#sec-corrhyp`, `#sec-corrhyp2`, `#sec-regressioncoefs`, `#sec-regressionassumptions`, `#sec-regressiondiagnostics`, `#sec-regressionoutliers`, `#sec-regressionnormality`, `#sec-regressionlinearity`, `#sec-regressionhomogeneity`, `#sec-regressioncollinearity` and `#sec-modelselreg`. References to already-translated chapters/sections (`@sec-correl`, `@sec-posthoc`, `@sec-shapiro`, `@sec-boxplotoutliers`, `@sec-transform`, `@sec-mathfunc`, plus file links into [Comparing several means (one-way ANOVA)](14-anova.qmd) and [The $t$-test](13-ttest.qmd)) are real cross-refs, confirmed to exist before use. The forward reference to *Factorial ANOVA* (standardised-coefficients footnote, re: regressors vs. predictors) stays as plain bracketed text, since Chapter 16 is still an untranslated placeholder — same convention as forward references elsewhere.

## Chapter 16 (Factorial ANOVA)

Translated in full (see [16-anova2.qmd](16-anova2.qmd)), the fifth and final chapter of Part V and the largest chapter translated so far. Notes:

- **Data files**: added `rtfm.Rdata` (`rtfm.1`, `rtfm.2`, `rtfm.3`) and `coffee.Rdata` (`coffee`) to `data/`; `clinicaltrial.Rdata` (`clin.trial`) was already present from Chapter 12.
- **New package dependency**: `effects` (for `effect()`/`Effect()`) wasn't previously needed. Installed via `pak::pak()` and added to the CI workflow's package list, alongside `lsr`/`car`/`sciplot`/`gplots`.
- **Every numeric result reproduces exactly**: verified live against the original before translating — `model.1`/`model.2`/`model.3` ANOVA tables, the hand-calculated `SS.drug`/`SS.therapy`/`SS.tot`/`SS.res` walkthrough, `etaSquared()` for both models, `effect()`/`Effect()` estimated means and confidence intervals, `leveneTest()`, `shapiro.test()`, the `model.1` vs `model.3` omnibus $F$-test walkthrough, the full ANOVA-as-regression equivalence demonstration (`rtfm.1`/`rtfm.2`/`rtfm.3`, `expandFactors()`, `drug.regression`/`nodrug.regression`), all four contrast-matrix functions, `TukeyHSD()` for both `model.2` and `model.3`, and the entire unbalanced-design section (Type I/II/III `anova()`/`Anova()` tables for the `coffee` data, both contrast-sensitivity demonstrations, and the "missing variance" `etaSquared()` calculation) all reproduce the book's numbers exactly. This is now the fifth Part V chapter in a row (after 12–15) with no numeric drift requiring a presentational accommodation — a first for a chapter this size and this heavy on live model-fitting.
- **Figures ported from `_original-text/scripts/factorialAnovaImages.R`**: `@fig-maineffects` (four $2\times2$ main-effect patterns) and `@fig-interaction` (four qualitatively different interactions) both come directly from the script's `anova2Img$effects()` function, refactored into a single reusable `me.plot()` helper (matching the Chapter 13 precedent of inlining a script's per-call plotting code into a small local function) rather than kept as eight separate one-off calls. `@fig-interactionplot` (the `lineplot.CI()` interaction plot) and `@fig-normalityanova2` (histogram/QQ plot of `model.2`'s residuals) have no generating script at all — both are one-line/two-line calls on already-fitted objects, so they're just live chunks like everything else in the chapter, consistent with the Chapter 14/15 precedent for figures that don't need a bespoke script.
- **`leveneTest()` error kept live**: the original shows `leveneTest(model.2)`/`leveneTest(mood.gain ~ drug + therapy, clin.trial)` producing a real error (`Model must be completely crossed formula only`), which the text itself goes on to explain and work around. The live chunk uses `error: true` to reproduce this exactly, rather than paraphrasing the error message — consistent with the Chapter 12 precedent of showing genuine warnings/errors inline (e.g. the Salem continuity-correction warning) rather than describing them in prose.
- **`Effect()`/`effect()` capitalisation kept as in the original**: the chapter genuinely uses both `effect()` (lowercase, from the worked `drug*therapy` example) and `Effect()` (capitalised, in the `rtfm` regression-equivalence section) — these are two distinct functions in the `effects` package, not a typo, so both are reproduced exactly as the original uses them.
- **Tables**: the population/sample mean tables (@sec-factanovahyp), the model-comparison hypothesis tables (@sec-omnibusF, @sec-anovalm), the expected-grades table, the three contrast-matrix tables, and the entire Type I/II/III null-vs-alternative model tables (including the three-way-ANOVA reference tables) are all hand-written Quarto/pandoc markdown tables, consistent with the established convention — this chapter has by far the most such tables of any chapter so far, reflecting how much of its content is naturally tabular (model comparisons, contrast matrices).
- **Citations**: `Hsu1996` was already present in `references.bib` from Chapter 14's Post hoc tests section; no additions were needed. This chapter has no epigraph (the original has none for Chapter 16), unlike most other chapters.
- **Cross-references**: this chapter defines `#sec-anova2`, `#sec-factorialanovasimple`, `#sec-factanovahyp`, `#sec-interactions`, `#sec-effectsizefactorialanova`, `#sec-factorialanovaassumptions`, `#sec-omnibusF`, `#sec-anovalm`, `#sec-changingbaseline`, `#sec-contrasts`, `#sec-posthoc2`, `#sec-plannedcomparisons` and `#sec-unbalancedanova`. References to already-translated chapters/sections (`@sec-anova`, `@sec-anovaandt`, `@sec-etasquared`, `@sec-levene`, `@sec-anovanormality`, `@sec-otherdists`, plus file links into [The $t$-test](13-ttest.qmd), [Linear regression](15-regression.qmd) and [Introduction to probability](09-probability.qmd)) are real cross-refs, confirmed to exist before use. This is also the **first chapter whose own forward references have all been resolved on first translation** — every other chapter that references Chapter 16 ([Comparing several means](14-anova.qmd), [The $t$-test](13-ttest.qmd), [Categorical data analysis](12-chisquare.qmd), [Linear regression](15-regression.qmd)) is already translated, so there was nothing left to log as a forward-reference follow-up here (unlike every other chapter's notes above). Chapter 16 itself has no forward references either, since Chapter 17 (Bayesian statistics) is never mentioned in the original text.

## Chapter 17 (Bayesian statistics)

Translated in full (see [17-bayes.qmd](17-bayes.qmd)), the last numbered chapter of the book and the final chapter of Part VI ("Endings, alternatives and prospects"). Notes:

- **New package dependency**: `BayesFactor` (for `contingencyTableBF()`, `ttestBF()`, `regressionBF()` and `anovaBF()`) wasn't previously needed anywhere in the book. Installed via `pak::pak()` (current CRAN release, 0.9.12-4.8) and added to the CI workflow's package list, alongside `lsr`/`car`/`effects`. Set `options(BFprogress = FALSE)` in the hidden `load-packages` chunk so the package's textual progress bars (emitted by `regressionBF()`/`anovaBF()` during model enumeration) don't leak into the rendered output.
- **No new data files**: every data set this chapter needs (`chapek9.Rdata`, `harpo.Rdata`, `chico.Rdata`, `parenthood.Rdata`, `clinicaltrial.Rdata`) was already present from Chapters 12, 13, 5/15 and 12/16 respectively. The small `toys` hypergeometric-sampling example has no source file in the original either (it's built inline from the numbers quoted in prose), so the translation constructs it the same way with a literal `matrix()` call.
- **Every Bayes factor reproduces exactly (with one expected exception)**: verified live against the original before translating — `contingencyTableBF()` under all four sampling plans (joint multinomial 15.9:1, Poisson 28.2:1, independent multinomial 8.6:1, hypergeometric 8.3:1 for the `toys` data), `ttestBF()` for both the independent-samples (`harpo`, ~1.75:1) and paired-samples (`chico`, ~5992:1) examples, and the full `regressionBF()` walkthrough (`dan.sleep` alone at $1.6\times10^{34}$:1, the `head()`/`max()`/model-ratio tricks, and the `whichModels = "top"` output) all matched the book's numbers essentially exactly (to within the trivial last-digit Monte Carlo jitter the package itself reports via its `±...%` margins). The one exception is `anovaBF()` on `mood.gain ~ drug * therapy`: the package now uses Monte Carlo integration (not the closed-form calculation used for the simpler tests) to compute Bayes factors for any model with more than one term, and repeated runs show the `drug + therapy` and `drug + therapy + drug:therapy` models' Bayes factors (both around 700, matching the book's 698.3/688.3) are close enough that *which one comes out on top* varies from run to run — confirmed by re-running the live chunk multiple times with different seeds. The surrounding prose was adjusted to describe this qualitatively (the two models are closely matched competitors) with a footnote explaining the Monte Carlo variability, rather than asserting a specific "best model" or hardcoding the book's exact ratios, consistent with the live-simulation precedent set in Chapter 10 for numbers that are expected to vary across renders.
- **`fig:type1` (the Type I error "peeking" simulation) not reproduced**: the original's single figure in this chapter is built from a two-stage pipeline (`_original-text/scripts/bayesnhst.R` then `falsepositives.R`) that runs $1000\times1000$ independent-samples $t$-tests *and* an equal number of `ttestBF()` calls — on the order of a million Bayesian $t$-test evaluations in total — to trace out the cumulative Type I error rate under continuous data-peeking. This is drastically more expensive than any other simulation figure in the book (Chapter 10's live Monte Carlo figures top out at a few thousand replicates) and isn't feasible to re-run live within a reasonable render time. Rather than silently drop it, added an explanatory paragraph at first mention describing exactly what the original pipeline computes and why it isn't reproduced, while keeping the book's own qualitative punchline (49% Type I error rate under continuous $p$-value peeking, versus a much lower rate under a 3:1 Bayes-factor stopping rule) in the surrounding prose. This is a new kind of omission for this book — every previous "figure not reproduced" case (Chapters 5, 6, 10, 15) was because the figure was hand-drawn/pedagogical with no real generating computation, not because the real computation was too expensive to run live — so it's logged here for visibility even though the *rationale* (don't fake being "live") is the same one behind the Chapter 5 follow-up.
- **Two commented-out epigraphs omitted**: the LaTeX source has two additional chapter-opening epigraphs (a Deming/uncredited quote, and an E.T. Jaynes quote) wrapped in `%\begin{quote}...\end{quote}` comments, alongside the live David Hume epigraph that actually appears in the typeset book. Followed the LaTeX literally and included only the Hume epigraph, per the Chapter 4/8 precedent for the same kind of commented-out-vs-bookdown-included divergence (checked: `_bookdown-adaptation/06.17-bayes.Rmd` also only uses the Hume epigraph, so there's no divergence to reconcile here).
- **Bare `\item` lists converted to ordered/bullet lists**: the four sampling-plan descriptions in @sec-bayescontingency (bold-lead-in bullet list, matching the Chapter 14 convention for the same LaTeX pattern), the four "what should you do?" options and their four-item elaboration in @sec-whybayes (both converted to ordered lists, since the original's own prose refers to them by number, e.g. "let's start with option 1").
- **Citations**: `Jeffreys1961`, `Kass1995`, `Johnson2013`, `Fisher1925`, `Gunel1974`, `Morey2015`, `Rouder2009`, `Kruschke2011` and `Lee2014` were all already present in `references.bib` from the Phase 1 bibliography port; no additions were needed.
- **Cross-references**: this chapter defines `#sec-bayes`, `#sec-basicbayes`, `#sec-bayesianhypothesistests`, `#sec-whybayes`, `#sec-bayescontingency`, `#sec-ttestbf`, `#sec-bayesregression` and `#sec-bayesanova`. References to already-translated chapters/sections (`@tbl-probrules`, `@sec-pvalue`, `@sec-whywhywhy`, `@sec-pairedsamplesttest`, `@sec-unbalancedanova`, `@sec-anovalm`, plus file links into [Hypothesis testing](11-hypothesistesting.qmd), [Categorical data analysis](12-chisquare.qmd), [The $t$-test](13-ttest.qmd), [Linear regression](15-regression.qmd) and [Factorial ANOVA](16-anova2.qmd)) are all real cross-refs, confirmed to exist before use — every chapter this one references is already translated, so (like Chapter 16) there was nothing left to log as a forward-reference follow-up. **Also resolved**: the three earlier plain-bracketed `[Bayesian statistics]` forward references in Chapters 9–11, converted to real `@sec-bayes` cross-refs now that this chapter exists.

## Chapters 13–17: proofreading pass for consistency

Audited Chapters 13–17 together for structural/presentational consistency, mirroring the
[Chapters 1–8](#chapters-18-proofreading-pass-for-consistency) and
[Chapters 9–12](#chapters-912-proofreading-pass-for-consistency) audits above (content
correctness stays in Phase 4). Checked: `load-packages`/`{{< include _setup.qmd >}}`
placement and chunk options, chapter/section heading levels and `#sec-` ids, footnote
syntax, key-term bold-italic markup (`**_term_**`), `data/*.Rdata` load paths, `fig-`/`tbl-`
chunk-label and caption conventions, epigraph attribution formatting (`---` em dash),
citation style and key existence, leftover LaTeX escapes/macros/curly quotes, "Rstudio"
spelling, "data set" vs "dataset" spelling, `callout-note` usage, and the `BLAH BLAH
BLAH`/`trunc-head`/`trunc-tail` truncation convention. One inconsistency found and fixed;
everything else checked out:

- **Fixed**: Chapter 15's hidden data-setup chunk (the one that builds the small simulated
  data set and `plot_anomaly()` helper shared by @fig-outlier, @fig-leverage and
  @fig-influence) was labelled `fig-anomaly-setup`, even though it's an `include: false`
  chunk with no `fig-cap` that produces no figure of its own — every other chunk of this
  kind in the book (e.g. the `load-packages` chunks, Chapter 13's
  `setup-truncated-output`) uses a plain, non-`fig-`-prefixed label, reserving the `fig-`
  prefix for chunks that actually render a captioned, cross-referenced figure. Renamed to
  `setup-anomaly-plots`; confirmed nothing referenced the old label via `@fig-anomaly-setup`
  before renaming, and re-rendered the whole book to confirm no regressions.
- Verified every `fig-`/`tbl-`-labelled chunk in Chapters 13–17 has a corresponding
  `fig-cap`/`tbl-cap`, and that Chapter 17 has zero figures (expected — its one figure,
  `fig:type1`, was deliberately not reproduced; see that chapter's notes above).
- Verified Chapters 13–16 have no epigraph at all, and confirmed against the LaTeX source
  that none of the four originals has a `\begin{quote}` immediately after `\chapter{}`
  either — not a missing-epigraph omission, just a genuine feature of those four chapters.
  Chapter 17's Hume epigraph uses the standard `---` em-dash attribution.
- Verified every citation key used in Chapters 13–17 already exists in `references.bib`,
  and that `quarto render` produces zero unresolved-citation or unresolved-cross-reference
  warnings across the whole book.
- Confirmed no leftover LaTeX macros (`\cite`, `\section`, `\chapter`, `\item`, `\rtextverb`,
  `\FOOTNOTE`, `Section@ref`/`Chapter@ref`, curly quotes `` `` ``/`''`, etc.) survived
  translation in any of the five chapters. The apparent matches for ``` `` ``` `` turned out
  to be triple-backtick code-fence delimiters caught by an overly broad `grep`, not real
  leftover LaTeX quotes.
- Investigated an apparent mismatch between the number of `BLAH BLAH BLAH` markers in each
  original chapter and the number of `trunc-head`/`trunc-tail` chunk options in the
  corresponding `.qmd` (e.g. Chapter 16's original has 10 `BLAH` markers but the translation
  only uses `trunc-head`/`trunc-tail` once) and confirmed this is not an inconsistency: most
  of Chapter 16's `BLAH` markers hide a `summary()` call's boilerplate around a coefficients
  table, and the translation instead uses `coef(summary(...))` throughout — exactly the
  alternative the original's own footnote at that point suggests ("you can use the `coef()`
  function to do the same job ... you'll get exactly the same output ... minus the `BLAH BLAH
  BLAH`"). Chapter 17's three `trunc-head`/`trunc-tail` chunks were individually checked
  against the original: two (the `associationTest()` output, and `summary(model)` for the
  `parenthood` regression) map directly onto real `BLAH BLAH BLAH` markers; the third
  (`independentSamplesTTest()`) has no corresponding `BLAH` marker in the original, which
  instead skips showing the verbose output at all and jumps straight to a hand-typed "Test
  results:" summary. Reproducing the real, truncated live output there (rather than
  hand-typing just the final numbers) is a reasonable extension of the technique consistent
  with "prefer live execution" — a deliberate translation choice already made and working
  correctly, not a structural bug, so it's noted here for visibility rather than changed.
- Investigated a handful of `##`-level headings with no `#sec-` id (e.g. Chapter 13's "The
  one-sample $z$-test" and "One sided tests", beyond the universal id-less `## Summary`
  heading every chapter has) and confirmed this is not a regression specific to Chapters
  13–17: the same pattern already exists in Chapters 11 and 12 ("Running the hypothesis test
  in practice", "What's the difference between McNemar and independence?"), so it predates
  this audit and is consistent with the rest of the book rather than a new inconsistency.
- Similarly investigated `###`-level subsection ids that appear to be unreferenced anywhere
  in the book (`#sec-lm` and `#sec-corrhyp2` in Chapter 15) and found the same thing is true
  book-wide — a `grep` across every chapter turned up 14 similarly unreferenced `###` ids
  spread across Chapters 3, 4, 7, 8 and 10 as well. This means the "###-level subsections
  carry ids only where something actually cross-references them" description in the
  Chapters 9–12 audit notes above was a slight overstatement of the book's actual, looser
  practice (many meaningfully-titled subsections get an id whether or not anything currently
  links to it) rather than a rule Chapters 13–17 have broken; left alone rather than stripped,
  since these are harmless, potentially useful anchors for future cross-references.
- No "Rstudio" mentions in Chapters 13–17 (none of these chapters discuss the IDE), and
  "data set" spelling is used consistently (no "dataset") across all five chapters, mirroring
  the pattern already established in the Chapters 1–8 and 9–12 audits.
- Verified `callout-note` is used exactly once across all five chapters (Chapter 14's
  `\advanced{}` section), matching the convention established in that chapter's own notes;
  no other chapter in this range misuses a callout for ordinary content.
- Confirmed via `quarto render` (whole book, no warnings/errors) both before and after the
  one fix above that nothing else regressed.

## Epilogue and references.qmd

Translated both remaining pieces of back matter in full (see [epilogue.qmd](epilogue.qmd) and [references.qmd](references.qmd)), completing the translation of every chapter and end-matter page listed in the chapter-correspondence table in [AGENTS.md](AGENTS.md).

- **Epilogue is pure prose, like Chapter 2 and the Part IV intro**: no code, no data, no figures, no `{{< include _setup.qmd >}}` — just the Lewis Carroll epigraph and three large bulleted "wish list" sections (omissions within covered topics, missing statistical models, other approaches to inference, miscellaneous topics) followed by a closing essay ("Learning the basics, and learning them in R"). `\underline{...}` emphasis (used a handful of times in the original, e.g. `\underline{lot}`) was translated to plain italics rather than literal underlining, following the precedent already set for the same LaTeX command in Chapter 4 (`\underline{\it Infinity}` etc. became plain italics there too).
- **`\ITEM{Title}` macro converted to bold-italic key-term bullets**: the original defines a one-off macro, `\newcommand{\ITEM}[1]{\item {\bf #1.}}`, used to start ~20 bulleted "topics I wish I'd covered" items with a bolded title. Translated each as `- **_Title_**. Body...`, matching the existing `**_term_**` bold-italic key-term convention (e.g. the reliability-types list in Chapter 2) rather than inventing a new bold-only convention for this one-off macro.
- **Extensive backward cross-references, all resolved**: this is the first chapter in the book whose *every* cross-reference is backward-looking (to already-translated chapters), since it's the very last piece of content — so unlike every other chapter's notes above, there was nothing to log as a forward-reference follow-up. Converted `Chapter~\ref{ch:...}` and `Section~\ref{sec:...}` throughout to real file links / `@sec-` cross-refs: `#sec-descriptives`, `#sec-transform`, `#sec-mathfunc`, `#sec-regressionlinearity`, `#sec-anova2`, `#sec-regression`, `#sec-studydesign`, `#sec-datahandling`, `#sec-estimation`, `#sec-hypothesistesting`, `#sec-bayes`, `#sec-chisquare`, `#sec-probability` and `#sec-missing` all confirmed to exist before use.
- **`wrapup.tex` folded into `references.qmd`, no separate chapter**: per the Phase 1 decision already recorded in PLAN.md, `wrapup.tex`'s content (a short author's note apologising for the incomplete bibliography, originally typeset directly above where the LaTeX master file `\include`s the bibliography) is presented as the lead-in paragraph of `references.qmd`, immediately before the `::: {#refs} :::` div that renders the actual bibliography. Dropped the placeholder `callout-note` wrapper that had been standing in for this content since Phase 1, since the note is genuine authorial prose in the book's own voice (an aside, not a flag for advanced/optional material), so it reads as ordinary paragraph text rather than a boxed callout — consistent with how the epilogue's own asides are handled, and distinct from the `callout-note` convention reserved for the LaTeX `\advanced{}` macro (see Chapter 14's notes).
- **Original's `\hrulefill` visual separator omitted**: the LaTeX source draws a literal horizontal rule between the end of the epilogue and the start of the reference-list note, a page-layout artifact of the print book that has no obvious Quarto equivalent and isn't needed once these are separate, distinct pages in a web book.
- **Whole-book render confirms all cross-references resolve**: verified via `quarto render` (whole book) that the newly-added `@sec-` and file-link cross-refs in the epilogue all resolve to the correct chapter/section anchors, with no unresolved-xref or duplicate-label warnings anywhere in the book.

## Issues to address (second pass)

Log anything noticed during translation that should *not* be fixed yet.
Add rows as they come up.

| Chapter | Location | Issue | Notes |
|---|---|---|---|
| 5 | `sort(afl.margins)` example | Original bolds the two median values (`30`, `31`) directly in the typeset R output. Live R output can't carry that inline styling, so the translation just states the values in prose instead of bolding them in the code output. | Presentational accommodation for live execution, not a content fix — logged for visibility rather than because it's an "error." |
| 5 | `describe(parenthood2)` table | Original truncates this table's *columns* (trailing `BLAH` per row) purely due to the printed page's fixed width. The translation shows the full live table instead — see the callout left in the chapter text. | Same rationale as above: a page-width artifact that doesn't apply to a digital book, not a statistical error. |
| 5 | `aggregate(formula = ..., data = ..., FUN = ...)` | R itself renamed `aggregate()`'s first formula argument from `formula` to `x` at some point after this book was written, so the original's explicit `formula = ` call now errors. Translation calls it positionally instead, with an inline comment explaining why. | A base-R signature change over time, not a book error — logged for transparency, not for "fixing" per se (the code has to run). |
| 5 | Cross-references to later chapters (`[Estimation]`, `[Probability]`, `[ANOVA]`) | Still written as plain bracketed text, because chapters 9, 10 and 14 are still placeholders without section ids. `[Graphics]` and `[Data handling]` (the same row's other two targets) have since been converted to real `@sec-graphics`/`@sec-datahandling` cross-refs now that chapters 6–7 are translated. | Follow-up: convert the remaining three to proper `@sec-` cross-refs once chapters 9, 10 and 14 are translated and have real section ids. |
| 7 | Cross-references to earlier chapters (`[Getting started with R]`, `[R mechanics]`, `[Drawing graphs]`) | **Resolved.** Converted to real `@sec-introR`/`@sec-mechanics`/`@sec-graphics` cross-refs now that chapters 3, 4 and 6 are translated and have section ids. | Verified via `quarto render`: all resolve to the correct chapter numbers/links, no unresolved-xref warnings. |
| 7 | `importList()` interactive prompt | Original shows R pausing for `y`/`n` console input; live rendering can't do this, so the chunk uses `ask = FALSE` with the original transcript kept alongside as a non-executed illustration. | Presentational accommodation for non-interactive rendering, not a content fix. |
| 8 | Cross-references to earlier chapters (`[Getting started with R]`, `[R mechanics]`, `[Pragmatic matters]`) | **Resolved.** Converted to real `@sec-introR`/`@sec-mechanics`/`@sec-datahandling` cross-refs now that chapters 3, 4 and 7 are translated and have section ids. | Verified via `quarto render`: all resolve to the correct chapter numbers/links, no unresolved-xref warnings. |
| 8 | `if`/`else` day-of-week example | Original hardcodes "Since today happens to be a Tuesday" as prose, matching whatever day the author happened to run the example. Translation uses a live inline `` `r weekdays(Sys.Date())` `` expression instead, so the day mentioned in prose always matches the live `source()` output below it, but will read differently depending on the day the book is rendered. | Presentational accommodation for live execution, not a content fix — logged for visibility since the displayed day will vary across renders/builds. |
| 3 | Installation instructions (`sec:gettingR`) | Original describes R 3.0.2 ("Frisbee Sailing") and Rstudio 0.98.501 (beta), CRAN/Rstudio download URLs and page layouts from 2013/2014, all now outdated. Kept verbatim per the faithfulness-first rule. | Follow-up: decide in Phase 4 whether to rewrite this section for the current R/RStudio/Positron installation experience, or add a framing note that the specific version numbers and screenshots are historical. |
| 3 | `sales.by.month * 7` and `profit / days.per.month` | Original's hand-typed output shows `0` for May in both examples, even though the vector's 5th element had just been corrected to `25` two subsections earlier — internally inconsistent within the original text. Translation executes the code for real, so it shows the self-consistent values (`175` and `~5.65`) instead of matching the original's `0`. | A likely transcription slip in the original (output not updated after a later revision added the vector-editing example), not a statistical error — logged for transparency since live execution necessarily diverges from the original's printed numbers here. |
| 4 | "A few extra comments" (package dependency demo) | Original uses `library(Matrix)` to demonstrate a dependency-loading message (`Loading required package: lattice`) and subsequent detach-protection. As of the current `Matrix` release, this no longer happens at load time. Translation substitutes `car`/`carData`, which reproduce the same two behaviours live today. | A real change in a CRAN package's own behaviour over time, not a book error — logged for transparency since the specific packages named differ from the original. |
| 4 | `group == gender` (unlabelled factors) | Original shows this comparison succeeding (returning a vector of `TRUE`/`FALSE`) before factor levels are labelled, and only erroring afterward once the labels obviously disagree. Current R's `Ops.factor` refuses to compare two factors with different level *sets* at all, so both the "before" and "after" comparisons now error identically. Translation shows both as live errors and adjusts the prose accordingly. | A base-R behaviour change (`Ops.factor` became stricter) rather than a book error — the modernised behaviour actually anticipates the section's own point about factors a step earlier than the original text does. |
| 4 | `print.formula(my.formula)` | Original calls `print.formula()` directly to show it produces output identical to `print(my.formula)`. This S3 method is no longer exported for direct use in current R (calling it now raises `could not find function "print.formula"`); `_bookdown-adaptation` already flagged this as "Appears to be deprecated." Translation shows the live error and reframes the surrounding prose around it. | A base-R namespace change over time, not a book error — the resulting error is, if anything, a fitting (if accidental) illustration of the method-dispatch point the section is making. |
| 4 | `?load` / `help("load")` walkthrough | `help()`/`?` open the Help pane rather than returning text a knitr chunk can capture, so this walkthrough is a non-executed transcript rather than a live chunk. The transcript quotes the *current* real text of `?load` (fetched via `tools::Rd2txt()`), which has gained a third `verbose` argument since the original was written, rather than hand-copying the original's 2013-era wording. | Presentational accommodation for non-capturable Help-pane output, not a content fix — logged since the quoted help text is deliberately newer than what the original shows. |
| 4 | Installation/version references (Rstudio, "the packages panel") | Chapter continues to refer to "Rstudio" throughout (per the faithfulness-first rule), with footnotes noting the Positron equivalent where the UI element in question (packages panel, environment panel, file panel, Import Dataset) has a direct counterpart. | Same follow-up as the Chapter 3 installation-instructions entry above: revisit in Phase 4 whether to rewrite this chapter's UI-specific sections around Positron directly rather than via footnotes on an Rstudio-framed original. |
| 10 | Simulated-IQ prose throughout the chapter (e.g. "the mean IQ in this sample turns out to be exactly 95") | Original hardcodes the specific numbers from one particular run of each simulation. Translation runs every simulation live (no `set.seed()`, consistent with Chapters 1–9) and quotes the actual computed values inline, so the specific numbers shown will differ from the original book and will vary from one render of this book to the next. | Presentational accommodation for live execution, not a content fix — logged for visibility since specific quoted values (sample means, counts of confidence intervals missing the true mean, etc.) are expected to change across renders. |
| 11 | Cross-references to Chapter 12 (`[Categorical data analysis]`, ×2) | **Resolved.** Converted to real `@sec-chisqreport`/`@sec-chisqindependence` cross-refs now that Chapter 12 is translated and has section ids. | Verified via `quarto render`: both resolve to the correct section numbers/links, no unresolved-xref warnings. |
| 14 | Two footnotes near `\advanced{}` section on the meaning of $F$ | Original has `$Q=(\sum_{k=1]^G N_k \alpha_k^2)/(G-1)$` and `$1 + \frac{2]{df_2 - 2}$`, both with a stray `]` where a `}` belongs. Translation fixes both to `$Q=(\sum_{k=1}^G N_k \alpha_k^2)/(G-1)$` and `$1 + \frac{2}{df_2 - 2}$` so the math actually renders. | Almost certainly a LaTeX transcription slip (mismatched bracket/brace), not a statistical error — fixed because an unmatched delimiter breaks MathJax rendering rather than just reading oddly, the same rationale as the base-R-signature-change fixes logged for Chapters 4–5. |
| 5, 9, 12, 13 | Cross-references to Chapter 14 (`[ANOVA]`, ×4: one each in Chapters 5, 9, 12, and one each of two in Chapter 13) | **Resolved.** Converted to real cross-refs now that Chapter 14 is translated and has section ids: Chapter 5's whole-data-set reference and Chapter 12's "analysis of variance" mention became file links to [Comparing several means (one-way ANOVA)](14-anova.qmd); Chapter 9's sum-of-squares/$F$-test mention and Chapter 13's notation footnote became `@sec-anovaintro`; Chapter 13's Levene-test mention became `@sec-levene`, the specific subsection where that test is actually discussed. | Verified via `quarto render` (both individually and whole-book): all four resolve to the correct chapter/section numbers and links, no unresolved-xref warnings. |
| 12 | Cross-reference to Chapter 13 (`[The $t$-test]`) | **Resolved.** Converted to a real `@sec-ttest` cross-ref. This was a pre-existing, previously unlogged gap left over from when Chapter 13 was translated after Chapter 12 (Chapter 12 still had `[Linear regression]` too, but that one stays as plain bracketed text since Chapter 15 remains an untranslated placeholder). | Verified via `quarto render` (both individually and whole-book): resolves to the correct chapter/section number and link, no unresolved-xref warnings. |


## Open questions

- Confirm final book title/author/metadata for `_quarto.yml`.
- Confirm target R package versions for reproducibility (original book is
  R 3.0.2-era). `lsr` itself is **no longer dormant** — it's under active
  development again toward a 1.0.0 release (see "Package dependency:
  `lsr`" below) — but the *other* dependencies (`psych`, `car`, `sciplot`,
  `gplots`, `effects`, `BayesFactor`) are still worth a version-pinning
  pass (e.g. `renv.lock`) once the translation itself stabilises.
- Decide whether to keep `lsr::` helper functions or replace with
  base/tidyverse equivalents (affects faithfulness vs. maintainability —
  default to keeping them for the first pass, per the guiding principle).

## Package dependency: `lsr`

Use the **dev branch** of the `lsr` package
(<https://github.com/djnavarro/lsr/tree/dev>), not the CRAN/archived
release, for any chunk that calls `lsr::`. The dev branch is on track to
become the 1.0.0 CRAN release and is more faithful to what readers will
encounter going forward than the old released version the original book
and the bookdown adaptation were written against.

- Install with `pak::pak("djnavarro/lsr@dev")` or
  `remotes::install_github("djnavarro/lsr", ref = "dev")` for local/manual
  work. **CI, however, pins a specific commit** rather than tracking
  `@dev` (see the 2026-07-12 update under "Proof of concept: Chapter 5"
  above) — check [.github/workflows/publish.yml](.github/workflows/publish.yml)
  for the currently-pinned SHA before assuming local and CI environments
  match, and bump the pin deliberately (not by re-running CI) when a new
  upstream fix needs to land.
- Note this as a setup step wherever the book's environment/dependencies
  are documented (e.g. a `renv.lock`, setup chapter, or README), so
  renders are reproducible.
- **2026-07-12: stress-tested the 1.0.0 release candidate** against every
  `lsr` function call used anywhere in the book, looking for bugs,
  beginner-confusing output, and fragility risks — see
  [PACKAGE-NOTES.md](PACKAGE-NOTES.md) for the full write-up. Seven issues
  found this way were fixed upstream in
  [lsr#25](https://github.com/djnavarro/lsr/pull/25) (now the pinned
  commit); several more are logged there as open/by-design items to keep
  in mind for future chapter edits (e.g. unused-factor-level handling in
  `goodnessOfFitTest()`/`associationTest()`, `wideToLong()`'s naming
  requirements). Re-run this kind of check if `lsr` is upgraded again
  before the book's release.
- Watch for behavior differences vs. the old `lsr` used in
  `_bookdown-adaptation` (e.g. the `etaSquared()` bug noted in its
  preface) — largely superseded by the more systematic stress test above,
  but still worth a glance if a specific bookdown-era workaround shows up
  during proofreading.
