With the Quarto edition live, readers immediately started filing sharp-eyed reports — thanks in particular to @gerard314 for four of them. Each report prompted a wider look, and two full read-throughs of the book followed. All fixes are prose/LaTeX/labels only; no analysis results change.
Reader-reported fixes:
- Ch 3: BTV/SEA described as origins when they are destinations (PR #575) and a Ch 5 wording fix (PR #577), both directly from @gerard314.
-
Ch 5: the first dummy-variable example carried a stale
$\mathbb{1}_{\text{Amer}}$ subscript from the first edition's "Americas" coding (reported in PR #578, completed with the neighboring stale subscripts in PR #579). -
Ch 5 (§ 5.2.2): every inline continent coefficient rendered as empty text — "the value + is the same difference…", equations ending without values, "here is + years." (issue #580). The hidden chunk filtered
get_regression_table()terms as"continent: Asia"where the term column actually readscontinent-Asia, so everypull()silently returnednumeric(0). Fixed in PR #581.
The two sweeps (PRs #579 and #581, ~125 fixes across 16 files) also caught, most notably:
-
Wrong numbers shown to readers: Ch 7's standard-deviation worked example used the wrong mean (2 instead of 4) making its answer
$\sqrt{17}$ instead of$\sqrt{13}$ ; Ch 8's displayed t-based 95% CI was computed from the wrong sample and contradicted the R output beside it; Ch 10's displayed 95% CI for$\beta_0$ was computed from$b_1$ , printing (−14.1, 14.9) around an intercept of 79.5; Ch 1'sflightsbullet rendered with its row count missing; the population-$\sigma$ formula was missing its square root in Chs 7–8; three Ch 6 equations carried 0.263 for a coefficient that renders 0.264. -
Stale first-edition leftovers: "five continents/Americas" descriptions in the six-continent UN data sections; "courses" (from the retired
evalsdata) surviving in Chs 5 and 10;temp-for-wind_speedremnants in Chs 2–3 (including a Learning Check whose solution still analyzed temperatures); defunct carriersVX/EVin Chs 2–3; promotions-era subscripts and wording in Ch 9's music-genre example. -
Alt-text corrections where descriptions contradicted the plotted data (swapped axes, a "Halloween dip" on the 9/9/99-births-spike chart, a "bell-shaped" claim about the deliberately non-normal almonds bowl), plus two wrong cross-references,
H_1→H_A, quartiles called "quantiles" in Appendix A, and assorted grammar.
Under the hood:
- renv pin for moderndive bumped 0.7.0 → 0.8.0 (now on CRAN); the Ch 1 cheatsheet footnote now documents the
View()that 0.8.0 actually exports for browser cells. webr-watch.ymlnow also watchespkg_extras(version-minimum test, report-only), so moderndive's wasm build landing on repo.r-wasm.org finally has a signal.
The Quarto edition — everything from 2.1.0 through 2.8.21 — is now what readers see at https://moderndive.com/v2/. v2-quarto-html was merged into v2 (PR #574), retiring the bookdown build of the second edition.
Reader-visible changes from the cutover itself:
- Every legacy URL keeps working. The old bookdown pages (unprefixed slugs like
getting-started.html, theappendixa/appendixAcase variants, extensionless forms,labs.html, and the tworegression-planepages) now 301-redirect to their Quarto equivalents. 60 redirect rules in total, each verified live after deploy. - Per-chapter R scripts are back. Bookdown generated the
scripts/NN-chapter.Rfiles each chapter links to at build time; Quarto did not. A newscripts/purl_chapters.R(run in CI after the render) regenerates them from the.qmdchapters viaknitr::purl(), so the "R script file of all R code used in this chapter" links stay live — now reflecting the current Quarto chapter code rather than the frozen bookdown copies. - The Preface's "About this book" section now summarizes the online edition's growth since Version 2.0.0 went to print.
Under the hood:
v2is now the single content branch: the Quarto sources, the deploy workflow (publishing to the live/v2withclean: trueso stale bookdown files are actually removed), the audit suite, and the webR runtime assets (data/mirrors +scripts/webr-shadow-library.R, which webR cellssource()from this branch's tip) all live here. The bookdown sources were removed; the pre-cutover bookdown tree remains at thev2branch history before the merge.- The webR shadow library was merged as a union of both branches' dataset registries (all 20 mirrored files verified present), so no interactive cell lost its data during the switch.
webr-watch.yml(the daily job that promotes companion packages once webR carries a real wasm build) now operates onv2instead of the retired development branch.data/le_mess.csvis shipped with the site again for LC 4.5'sread_csv()-from-URL exercise.
The instructor-solutions/ hub (worked solutions, facilitator notes, slide decks, syllabus, rubrics, exam bank, …) and the scripts/build_*.R report generators have been removed from this public repo. They now live in the private companion repo moderndive-instructor-resources (renamed from moderndive_exercise_solutions), alongside the exercise solutions — keeping answer keys, exams, rubrics, and teaching notes out of the public source tree.
- The public book is unaffected:
instructor-solutions/was always a separate Quarto project, never part of the book's render list. - The companion repo's CI clones this book, restores the instructor content into the tree, then renders + encrypts + publishes the hub as before.
- Shared pieces stay here: chapter qmds, the exercise prompts (
exercises/NN.yml), andscripts/exercise_helpers.R. .gitignorenow excludes/instructor-solutions/and/scripts/build_*.R, sosync_to_book.shcan restore them locally for rendering without risk of re-committing them publicly.
(The removed files remain in this repo's earlier git history — they were deleted going forward, not purged.)
The "Evaluating hidden code cell" delay students saw before any interactive cell was usable was dominated by read.csv(gzfile(...)) parsing 315 090 rows of olympic_athletes in wasm R. Switching the shadow library's CSV mirrors to R's native binary format (.rds) gives:
- ~50 % first-visit setup speedup — locally measured ch 11 setup (the heaviest, loads all four GitHub-only packages + the three moderndive top-ups) dropped from ~10–15 s to 6.2 s in real webR.
readRDS()skips CSV parsing entirely and is roughly 2× faster thanread.csv(gzfile())on the big file (benchmarked locally: 0.47 s vs 0.86 s; speedup is amplified in wasm). - ~37 % bandwidth reduction on the big file —
olympic_athletes.rdswithcompress = "xz"is 3.2 MB vs the previous 5.8 MB.csv.gz. The other 9 mirrors stay on default gzip (xz overhead isn't worth it under 1 MB; sizes within 10 % of the previous.csv.gz).
Concrete changes:
scripts/webr-shadow-library.R— file extensions.csv.gz→.rdsthroughoutpkg_dataandpkg_extras$moderndive;load_from_mirrorswapsread.csv(gzfile(tmp))forreadRDS(tmp).- Ten new
.rdsfiles indata/. The previous.csv.gzfiles are no longer referenced but left in place (orphan but harmless). - No curriculum or student-code impact: loaded data frames are identical.
Verified end-to-end with the Layer C headless-webR CI job (scripts/test_webr_headless/) — all 53 webR cells across chapters 1-11 + Appendix B pass.
Not pursued (yet): persistent webR filesystem cache via IDBFS for cross-visit caching. Quarto-webr doesn't expose a stable hook to mount the IndexedDB filesystem before cells run, and the bigger pain (first-visit latency) is already addressed by this change. Documented as a deferred enhancement.
The 2.8.16–2.8.18 webR work fixed bugs by hand, but nothing in the audit pipeline watched the webR surface — every regression slipped through until a student tried to run a cell. Three new jobs in .github/workflows/audits.yml now guard webR:
- Layer A — static scan (
scripts/audit_webr_symbols.R). Walks every{webr-r}cell in chapter qmds + Appendix B and everywebr:field inexercises/*.yml; flags bare data symbols that aren't loaded by the chapter's setup (vialibrary()— with shadow mapping for the four GitHub-only packages — or top-levelX <- …assignments) and aren't in webR's preloaded-package datasets or built-ins. Fast (<30 s), fails CI on any flag. - Layer B — server-side eval (
scripts/test_webr_cells.R). Installs the 9 webR-preloaded CRAN packages + the 4 GitHub-only ones + every other package exercise cellslibrary()(broom, MASS, conflicted, janitor, pwr, readxl, stringr), then runs every{webr-r}cell in plain R. Matches Quarto/webR ordering (#| context: setupfirst, then file order). Catches logic errors, wrong column names, undefined intermediates — bugs static analysis can't see. Caught the ch5UN_data_ch5rebind-with-wrong-columns bug on first local run — the line ~160 webR cell wasfilter-only (leaving columns namedlife_expectancy_2022), which silently clobbered the setup'sselect(life_exp = …, fert_rate = …)rename and broke every downstream cell. Fixed in this commit. - Layer C — headless webR-in-Node (
scripts/test_webr_headless/test_webr.mjs). Node script using@r-wasm/webr(pinned to 0.2.0) that initialises a real headless webR (browser-side R compiled to wasm), installs the preload list, and evaluates every cell withglobalenv()cleared between chapters. Surfaced a real webR runtime bug (see below) that would have stayed latent until someone clicked Run.
Supporting changes:
- Shadow
library()is now environment-aware (scripts/webr-shadow-library.R). The earlier version always loaded GitHub-only datasets from the CSV mirror, even in regular R where the package was installed.requireNamespace()check now means: real package installed → delegate tobase::library()(local R + Layer B CI); not installed → CSV-mirror path (webR + Layer C). Same student behaviour in both environments. - Shadow now uses
download.file() + read.csv(gzfile(tmp))instead ofreadr::read_csv(). Layer C surfaced that webR'sreadr::read_csv()hangs indefinitely on.csv.gzURLs (even tiny 50 KB ones) — gzip decoding from a remote stream isn't wired up in webR. It also hangs on plain.csvURLs (ch4'sdem_score <- read_csv(...)was the trigger). The base-Rdownload.file()+read.csv()chain works in both webR and regular R; verified locally withch1 setup(downloads + decodes the 5.8 MB olympic_athletes plus the two small olympicAthletes datasets) in 2.9 s. - Shadow now also tops up missing moderndive datasets after
library(moderndive)succeeds viabase::library. webR's binary moderndive (fromrepo.r-wasm.org) lags CRAN and silently lacks newer datasets that the book uses —envoy_flights(ch 2 viz examples),early_january_2023_weather(ch 2 line-graph), andun_member_states_2024(ch 5 / ch 6 UN regression chapters). After loading the package, the shadow checks each name and downloads the v2.csv.gzmirror only when the local install doesn't already have it. Three new tiny CSV mirrors land onv2:data/envoy_flights.csv.gz— 357 × 19, 7 KBdata/early_january_2023_weather.csv.gz— 360 × 15, 4 KBdata/un_member_states_2024.csv.gz— 193 × 39, 20 KB
- ch4 setup:
dem_score <- read_csv(URL, show_col_types = FALSE)→read.csv(URL). webR's readr hangs on every URL form, gz or plain. Baseread.csv()works identically in regular R.
The 2.8.16–2.8.18 work shipped a working pipeline by browser test alone; Layer C would have caught the readr-gz hang, the readr-plain-URL hang, and the three moderndive-lag bugs in CI on first push instead of mid-class.
A thorough audit after 2.8.17 turned up nine objects that exercise {webr-r} cells reference but that were never available in the webR namespace — each a pre-existing footgun. A student opening any later exercise in isolation would hit an "object not found" error because the definition lived in an earlier inline {webr-r} cell (or, for bball, was only described in an exercise prompt and never defined anywhere).
Pre-defined in each affected chapter's #| context: setup cell:
- Ch 4 (
04-tidy.qmd) — needed three additions.bob_long(the long-form pivot ofbob_ross's 67 indicator columns, referenced by EX 4.11).dem_score(read from thedata/dem_score.csvmirror — not in any preloaded package despite the EX 4.27 prompt's "frommoderndive" hint). Pluslibrary(olympicAthletes)(via the shadow) since ch 4 had no GitHub-only package loads but multiple exercises (EX 4.35/39/40/41) referenceolympic_athletes. - Ch 5 (
05-regression.qmd) —bball(olympic_athletes |> filter(sport == "Basketball", !is.na(height), !is.na(weight))), referenced across many later exercises. EX 5.1 still asks the student to construct it — their code just overwrites the pre-defined object. PlusUN_data_ch5(the four-variable UN member states subset shown in @sec-model1EDA), which downstream{webr-r}cells reference directly. - Ch 6 (
06-multiple-regression.qmd) —planets_lite(four non-missing exoplanet variables, EX 6.3) andplanets_temp(three non-missing variables, EX 6.15), both built by student exercises but referenced from EX 6.4/5/16/21/37/39/44–46/53. PlusUN_data_ch6(the factor-typed-income subset). - Ch 10 (
10-inference-for-regression.qmd) —bballagain. Roughly 11 ch 10 exercises (EX 10.20, 22, 37, 45–51, 54–55) reference it butbballwas never defined anywhere in the chapter — a pre-existing curriculum bug independent of the webR migration.
The "build X yourself" exercises (EX 5.1, 6.3, 6.15) continue to work as written; the student's code just overwrites the pre-defined object. Net effect: every exercise webR cell is now runnable in isolation, regardless of which order a student opens them.
Audit infrastructure: tmp/webr_audit.py and webr_qmd_cells.py flag bare data-symbol references in webr: fields and inline {webr-r} cells that aren't loaded by the chapter setup or webR's preloaded packages. The audit reports clean across all 11 chapters and Appendix B (14 cells).
- Shadow
library()for the four GitHub-only companion packages. 2.8.16 fixed broken chapter setups by routing GitHub-only datasets through inlinereadr::read_csv()calls — which worked, but it made the setup code diverge from the local-RStudio idiom, and any exercisewebr:starter that already wrotelibrary(olympicAthletes)(six of them: ex 1.6, 2.1, 3.1, 6.1, 7.1, 10.49) still errored. Newscripts/webr-shadow-library.Rdefines a shadowlibrary()that — forolympicAthletes/steves/exoplanetdata/volcanoesonly — reads each package's.csv.gzmirror intoglobalenv(). Every other package name delegates tobase::library()unchanged, solibrary(dplyr)/library(infer)etc. behave normally. Idempotent (repeat calls skip datasets already present). - Each chapter
#| context: setupcell now usessource(...) + library(...):Net −29 lines across the 10 chapters + Appendix B, and the code finally matches what students would type in local RStudio.source("https://raw.githubusercontent.com/moderndive/ModernDive_book/v2/scripts/webr-shadow-library.R") library(dplyr) library(ggplot2) library(olympicAthletes) # loads olympic_athletes + editions + medal_table via shadow
olympic_editions.csv.gz(62×15, 3 KB) andolympic_medal_table.csv.gz(1929×11, 16 KB) added solibrary(olympicAthletes)in webR transparently provides all three datasets — fixing latent breaks in ch 1 ex 13/15 (which callglimpse(medal_table)/tidy_summary(medal_table)) and ch 3 ex 24 (inner_join(editions, ...)).- Appendix B's two
read_csv()-based webR cells migrated to the samesource(...) + library(steves)pattern, eliminating the last inline mirror URL in the book. - Companion commit on
v2publishesscripts/webr-shadow-library.Rplus the two new.csv.gzfiles so all of the above URLs resolve.
- Restored interactive exercises across 10 chapters. webR (browser-side R) can only install packages from
repo.r-wasm.org, so each chapter's#| context: setupcelllibrary(olympicAthletes)/library(steves)/library(exoplanetdata)/library(volcanoes)call failed silently and tore down the per-page webR namespace — every downstream end-of-chapter{webr-r}exercise cell in chapters 1-3, 5-11 was broken. Setup cells now read each needed dataset from a gzipped CSV mirror onraw.githubusercontent.com/moderndive/ModernDive_book/v2/data/<file>.csv.gzviareadr::read_csv(). Datasets exported withreadr::write_csv()(auto-gzips on.gzextension):data/olympic_athletes.csv.gz— 315 090 rows × 16 cols, 5.8 MB (fullolympicAthletes::olympic_athletes)data/steves_episodes.csv.gz— 159 × 38, 50 KB (fullsteves::episodes)data/exoplanetdata_planets.csv.gz— 6 278 × 28, 377 KB (fullexoplanetdata::planets)data/volcanoes_eruptions.csv.gz— 11 089 × 14, 163 KB (fullvolcanoes::eruptions)data/volcanoes_volcanoes.csv.gz— 1 215 × 19, 442 KB (fullvolcanoes::volcanoes)
readradded towebr.packagesin_quarto.ymlso it's preloaded into every chapter's webR session alongside ggplot2/dplyr/etc. — needed to decode the gzipped mirrors transparently.- Companion commit on
v2publishes the same five.csv.gzfiles to that branch so the raw URLs resolve. (The bookdown v1 build onv2is unaffected — these are new files only.) - Appendix B steves reads consolidated. The two
read.csv("…/v2-quarto-html/data/steves_episodes.csv")calls added during the 2.8.14 Appendix B work now point at the gzipped mirror onv2viareadr::read_csv(), matching every other webR mirror read. The plaindata/steves_episodes.csv(6-col subset) committed during that earlier work is removed — superseded by the full 38-col.csv.gz.
- Per-chapter OG/Twitter descriptions. Each of the 11 main chapters (
01-…through11-…) now declares a topic-specificdescription:in YAML frontmatter so social-share previews (Open Graph + Twitter Card) surface a chapter-specific blurb instead of the book-level default. In a Quarto book project,book.descriptionfrom_quarto.ymlpropagates toog:descriptionandtwitter:descriptionon every chapter and overrides the page-leveldescription:; the override only reaches<meta name="description">. Each chapter's frontmatter therefore declares the string once with a YAML anchor (description: &desc "…") and references it (*desc) inside explicitopen-graph:andtwitter-card:blocks, so the same per-chapter blurb lands in all three meta tags. - Share image switched to the v2 hardcover.
_quarto.ymlnow pointsopen-graph.imageandtwitter-card.imageatimages/logos/v2_cover.jpg(the second-edition hardcover, already used as the visible cover on the landing page) instead of the hex logo. Twittercard-styledowngraded fromsummary_large_imagetosummaryso the portrait cover renders inside a square thumbnail to the left of the title rather than being center-cropped to a landscape band — the standard pattern for book share cards. - Removed duplicate hand-rolled OG block in
_includes/analytics.html. Predated Quarto's native open-graph + twitter-card support and was emitting a second copy ofog:title/og:description/og:image/og:url/twitter:cardin the page head with stale info (title hardcoded to "ModernDive V2",twitter:cardforced tosummary_large_imageregardless of the project setting, fixedog:url=https://moderndive.com/v2/on every page). Quarto's auto-emission with the per-chapter overrides above is now the single source of truth.
ModernDive 2.8.14 — webR exercise integrity, Appendix B interactivity + regression examples, glossary popovers
-
Stubbed 117 answer-revealing webR exercise starters across
exercises/02–11.yml. Manywebr:starter blocks shipped the complete worked answer to prompts that ask students to construct the code, defeating the exercise. Replaced with# your code here(normal groups) /# your exploration here(Extensions), preserving only genuine scaffold (aset.seed()for reproducibility, performance/constraint comments such as the loessO(n^2)note); solution-narrating comments were dropped. Run/interpret-the-output and given-snippet prompts were left intact. -
Appendix B CORS fix.
https://moderndive.com/data/*.csvreturns HTTP 200 but noAccess-Control-Allow-Originheader, so webR (a browser Web Worker) was blocked from loading data in the Try it interactively cells. Repointed the twoageAtMarwebR cells to the CORS-enabledraw.githubusercontent.com/moderndive/ModernDive_book/v2/data/mirror (byte-identical file). Plain{r}build chunks are unaffected (server-side, no CORS) and keep the canonical URL. -
Interactive webR throughout Appendix B. Added collapsible Try it interactively
{webr-r}callouts (hypothesis test + confidence interval,repsreduced to 1000 for in-browser speed) to all four remaining case studies — One proportion, Two proportions, Two means (independent), Two means (paired) — matching the existing One-mean pattern. Appendix B now has 14 runnable webR cells. -
New Appendix B section: Correlation and simple linear regression. Uses
steves::episodes(imdb_rating ~ overall_episode) — a dataset not used in any regression chapter. Permutation test for the correlation, bootstrap CI for the slope, theory-basedget_regression_table()counterpart, and two webR cells. Becausestevesis GitHub-only (not installable in webR), the needed subset is exported todata/steves_episodes.csvand the webR cells read it from the raw mirror. -
New Appendix B section: Multiple regression with
infer::fit(). Usessaratoga_houses(price ~ living_area + bathrooms + bedrooms,moderndivepackage — webR-preloaded). Observedfit()coefficients, response-permutation null, per-coefficient bootstrap CIs, and the theory-based table — with the distinction between the joint response-permutation null and the partial coefficient test made explicit. Two webR cells. -
Glossary hover popovers. Auto-linked glossary terms (first mention per chapter) now show the definition in a Bootstrap popover on hover/keyboard-focus while still linking to the full entry.
_extensions/glossary-autolink/glossary-autolink.luaextracts and cleans each definition (dropsSee @sec-…cross-refs and code/italic markup) and attachesdata-bs-*attributes;_includes/glossary-popover.html(wired viainclude-after-body) instantiates the popovers;style.cssadds a dotted-underline affordance and popover sizing. Inline math in a definition (e.g. the null hypothesis (H_0)) is rewritten from$…$to MathJax's default\(…\)delimiters and re-typeset withMathJax.typesetPromise()onshown.bs.popover, so equations render in the bubble instead of showing raw TeX.
scripts/build_lesson_plans.R→instructor-solutions/lesson-plans.html. Per-chapter teaching plan: learning objectives, section outline, Quick check / Learning check counts, exercise difficulty mix, and a class-time budget (150 wpm reading rate + 3 min/QC + 2 min/LC + 3 min/section overhead).scripts/build_homework_planner.R→instructor-solutions/homework-planner.html. Single self-contained page with all 486 exercises in a sortable table; client-side JS filters by chapter, difficulty, group, keyword, webr-only. Check boxes to assemble a set; click Export for a copy-pasteable list.scripts/build_slide_decks.R→instructor-solutions/slides/NN-slides.qmd× 11. Interactive revealjs decks themed in the ModernDive hex-sticker palette (navy#1F3A6B, blue#1A6FBE, green#76BC43). Each deck includes title + learning objectives + spaced-practice warm-up (Ch ≥ 2) + section dividers + per-section MCQ check-ins (parsed directly from each chapter's Quick checks: stem, options, correct letter, explanation) + wrap-up retrieval slide. Shared theme inslides/moderndive-slides.scssand tap-to-select / show-poll / show-answer interactions inslides/moderndive-slides.js. Learning-sciences design choices: frequent retrieval practice, predict-then-check prompts, single-idea slides,prefers-reduced-motionaware.scripts/audit_exercise_lexicon.R— dataset-cadence check tightened so dataset names only count as a forward-ref when they appear as code symbols (backticked,library()/data()call, or followed by,,$,[,(,%>%,|>). String literals inside webr labels (e.g.,labs(y = "medal events")) no longer false-flag.scripts/build_facilitator_notes.R→instructor-solutions/facilitator-notes/NN_notes.qmd× 11. Per-chapter teaching scaffold: auto-generated learning objectives, section-by-section breakdown with minute estimates, and stuck-points parsed from each Quick check's lettered options — paired with blank fill-in slots for cold open, cold-call moments, transition phrases between sections, group-work break prompts, exit ticket, and an after-class self-check. Published alongside the slides + worked solutions through the companion repo's gh-pages encrypted pipeline.scripts/build_syllabus.R→instructor-solutions/syllabus.qmd. Sample syllabus: 15-week US-semester layout + compressed 10-week quarter alternative + assessment plan (4 problem sets + midterm + final project) + per-unit learning outcomes auto-extracted from each chapter's "In this chapter, you'll learn how to:" callout. Renders to_site/syllabus.htmlas part of the project.instructor-solutions/moderndive-instructor.scss— shared hex-sticker-palette SCSS for the worked solutions, syllabus, slides landing, and facilitator notes pages. Mirrorsslides/moderndive-slides.scssso the whole instructor site reads as one visual product (navy headings with green underlines, blue links, cream.callout-tipblocks, ruled-paper fill-in code-block styling for the facilitator-notes blanks).scripts/build_slide_decks.R+scripts/build_facilitator_notes.R— learning-objective parser rewritten. The book uses::: {.callout-note title="In this chapter, you'll learn how to:"}(heading text lives in the callout's attribute, not in a## In this chapterline), and the old regex assumed the latter. Switched to grep-the-title-line + walk-to-closing-:::(same approach asbuild_lesson_plans.R), so LOs now appear correctly on every chapter's deck and notes page.instructor-solutions/_quarto.yml— render list now includes the slide decks, facilitator notes, AND syllabus. Companion repomoderndive-instructor-resourcesupdated to render the full project (instead of justindex.qmd) and to encrypt the whole_site/tree withstaticrypt -r, so the new artifacts ship to gh-pages under the sameINSTRUCTOR_PASSWORDgate.instructor-solutions/index.qmd— new callout block linking to all seven companion instructor artifacts so the worked-solutions page is the single navigation hub..github/workflows/audits.yml— setRENV_CONFIG_AUTOLOADER_ENABLED=FALSEso audit jobs skip the.Rprofileautoload. Without this, renv interceptsinstall.packages()and tries to resolve every GitHub-hosted lockfile entry against the unauthenticated GitHub API, which intermittently rate-limits and fails the Exercise YAML lint job.
- WCAG contrast audit of custom callouts (
.learncheck,.announcement,.review) in light and dark mode: all foreground/background pairs now verified at AAA. No CSS color changes needed. - Focus indicators: prominent
:focus-visibleoutline (blue in light mode, lighter blue in dark mode) — keyboard users can see which element has focus. prefers-reduced-motionsupport: users with reduced-motion OS preferences get all animations/transitions dialed down to 0.01ms.- Skip-to-main-content link scaffold in CSS (
.skip-linkclass), visible only on keyboard focus. - ARIA landmarks on custom callouts: new
_extensions/aria-callouts/Lua filter addsrole="region"and a descriptivearia-labelto.learncheck,.announcement, and.reviewdivs so screen-reader users can navigate between them as landmarks. (Quarto's built-in callouts already have these.)
- Glossary auto-link Lua filter (
_extensions/glossary-autolink/). On the first occurrence of each glossary term in each chapter, the prose now contains a hyperlink to the matching glossary entry. Multi-word terms ("sampling distribution", "Central Limit Theorem") and single-word terms ("scatterplot", "outlier") both supported. Excluded contexts: code, math, existing links, headings, the glossary chapter itself. Readers benefit from the glossary without needing to know it exists. - Per-page OpenGraph + Twitter-card metadata via
book:config (site-url,open-graph,twitter-card). Social-share previews now include the book hex logo + chapter title; per-chapter overrides still possible via YAML frontmatter.
scripts/lint_exercise_yaml.R— validates everyexercises/NN.yml: required fields (ex_num,difficulty,prompt), difficulty in 1..3, uniqueex_numwithin chapter, code-needing prompts withoutwebr(warning), orphan solutions (warning),book_sectionvalues matching real chapter section titles (warning). Wired into the Audits CI workflow so malformed YAML fails the PR before render.scripts/exercise_coverage_map.R— generatesinstructor-solutions/coverage-map.htmlwith per-chapter tables of section/subsection coverage, exercise-ID lists collapsed to en-dash ranges, and difficulty histograms. Sections with ≤ 1 exercise are flagged in red. Output is gitignored; regenerate on demand.
- Hover citations already enabled in
_quarto.yml(citations-hover: true) — bibliography refs preview on hover. - MathJax screen-reader accessibility: new
_includes/mathjax-assistive.htmlloads thea11y/assistive-mmlMathJax extension and enablesassistiveMml: trueso screen readers speak equations semantically rather than glyph-by-glyph. - Tighter
_freezecache key inquarto-publish.yml— hashes the root-level book qmds + helper scripts +exercises/*.ymlinstead of**/*qmd, so instructor-solutions edits don't invalidate the main book's freeze cache. - New
.github/workflows/audits.ymlwith three PR-gate jobs:- Dead anchors (runs
cross_reference_scans.R; fails on unresolved@sec-*/@fig-*/@tbl-*) - Figure alt-text (runs
alt_text_audit.R; fails if any figure ships without alt text) - External link check (
lychee; reports dead URLs as a downloadable artifact, doesn't block the PR)
- Dead anchors (runs
Locks in the 2.7.0 cross-ref/alt-text wins so future PRs can't regress.
Folder-and-file reorganization to give the repo a single home for every R / shell / Perl helper, decouple App C from legacy knitr caching, and consolidate the instructor-solutions sources next to their builder. No content changes — public reader-facing book is identical to 2.7.0.
Previously, helper code lived in three overlapping folders:
R/— render-time helpers, plus a couple of one-shot dev tools mixed in.scripts/— diagnostic audit scripts (added in 2.7.0)._tools/— bookdown→Quarto migration Perl scripts.
These all merged into scripts/, with a single source-of-truth scripts/README.md documenting each file by role (render-time, manual build, diagnostic audit, migration tool, archive). The table at the top of the README classifies every file. Internal organization:
- Top level — render-time helpers (
exercise_helpers.R,image_functions.R,setup_exercise_packages.R,post-render-cleanup.sh), manual build helper (pdf_build_from_tex.R), 4 diagnostic audits, 2 migration Perl scripts, V1→V2learning-checks/subdir. scripts/archive/— orphaned bookdown-era helpers kept for git-history reference (currently justpurl.R, whichindex.qmdno longer sources).
All R/-path references updated to scripts/: 18 chapter qmds, 11 exercise-solution qmds, _quarto.yml, internal references inside the migration scripts themselves.
Removed: duplicate pdf_build_from_tex.R (root copy stale; R/ version kept the same content but with current Quarto-era paths).
93-appendixC.qmd was the only chapter still using R Markdown's cache=TRUE chunk option, producing 93-appendixC_cache/ (8.5 MB of tracked binary cache that churned on every chunk-option change) and 93-appendixC_files/. Both directories deleted from tracking; the chunk option removed; the chapter now uses Quarto's _freeze like every other chapter. Net savings: ~9 MB and zero cache-file churn in future commits.
The three static HTML files referenced as resources in _quarto.yml (regression-plane.html, regression-plane-ISLR2.html — both ~4.5 MB interactive 3D plots — and labs.html — a 206-byte redirect) moved to extras/. The _quarto.yml resources: list now points to extras/<file>. Two follow-on updates:
- The Ch 6 prose link to
https://moderndive.com/v2/regression-plane-ISLR2.htmlupdated to.../v2/extras/regression-plane-ISLR2.html. _redirects(Netlify) gained three permanent redirects to preserve any existing inbound links to the pre-move URLs.
exercise-solutions/*.qmd (11 per-chapter solution stubs) moved into instructor-solutions/chapters/. The instructor-solutions/index.qmd include paths updated from ../exercise-solutions/NN_ex.qmd to chapters/NN_ex.qmd. The exercise-solutions/ directory is gone.
In the process, 20 MB of stale build artifacts (10 *_ex.html standalone renders plus 225 entries under *_ex_files/ for bootstrap CSS/JS/woff fonts) removed from tracking. The canonical instructor-solutions render is instructor-solutions/_site/index.html; the per-chapter HTMLs were leftover from when each chapter rendered standalone before the wrapper project existed.
.gitignore now defensively ignores exercise-solutions/ so a stray hand-render can't re-track those artifacts.
Heads-up for the companion moderndive-instructor-resources repo: its build.yml Cache step hashes book/R/exercise_helpers.R for the cache key — that path no longer exists. The single-line patch is:
- key: instructor-solutions-freeze-${{ hashFiles('book/exercises/**/*.yml', 'exercises/**/*.yml', 'book/R/exercise_helpers.R') }}
+ key: instructor-solutions-freeze-${{ hashFiles('book/exercises/**/*.yml', 'exercises/**/*.yml', 'book/scripts/exercise_helpers.R') }}(Not a build failure — the existing key just produces a cache miss every run, forcing a fresh render. Updating restores cache hits.)
A diagnostic-tooling release that puts the book's pedagogy and accessibility under explicit, repeatable scrutiny. Three read-only audit scripts now live in scripts/; their findings drove targeted refinements to the exercise system, Quick check coverage, distractor wording, and figure alt-text. The bookdown source remains canonical on the v2 branch; the Quarto build is published to v2-publish from v2-quarto-html.
Three self-contained R scripts that audit the book and print structured punch-lists, plus a README.md documenting use, output format, and known false-positive patterns. Each script is read-only — outputs are reviewed and applied separately.
scripts/pedagogy_scans.R— three scans in one pass: forward@sec-*cross-references (with Conclusion/foreshadowing prose filtered out), first-use lexicon for glossary terms, and a function-introduction map (prose-intro vs code-intro per function).scripts/learning_objective_scans.R— LC distribution per chapter/section, fuzzy QC-to-subsection alignment, and per-group exercise difficulty progression (flags groups with★★★exercises but no★★rung).scripts/alt_text_audit.R— figure alt-text accessibility audit covering R chunks (fig.alt=), markdownimages, andinclude_graphics()calls. Filters non-rendering chunks (eval=FALSE,fig.show='hide',{webr-r}, HTML-comment-wrapped markdown images) to suppress false positives.
-
~12 new end-of-chapter exercises added to fill depth/length-proportional gaps surfaced by the section-coverage audit, all as Extensions tagged to the section they target so the coverage tables update correctly:
- Ch 6 § 6.2 Two numerical predictors (EX 6.55–56): partial vs marginal slopes, residuals-vs-fitted diagnostic on the two-numerical model.
- Ch 7 § 7.2 Sampling framework (EX 7.45): six-term vocabulary paragraph.
- Ch 7 § 7.5.1 Two-sample sampling distributions (EX 7.46–47): SE-of-a-difference numeric check, center of the two-sample sampling distribution.
- Ch 8 § 8.3 Additional remarks about the bootstrap (EX 8.44): how many bootstrap replicates is "enough."
- Ch 9 § 9.3 Understanding hypothesis tests (EX 9.45–46): six-term vocabulary paragraph, "three things a
$p$ -value is not." - Ch 10 § 10.6 Simulation-based inference for multiple linear regression (EX 10.56–58):
infer::fit()bootstrap CI for each partial slope, permutation$p$ -value for each partial slope, when simulation-based beats theory-based. - Ch 11 § 11.1 Seattle case study (EX 11.20–21): scaffolded warm-ups on log-transforming
priceand predicting a single house price by hand from the fitted equation.
-
Ch 10 difficulty rebalanced — 12 exercises rerated from ★★★ to ★★ (EX 10.8, 10.10, 10.11, 10.13, 10.15, 10.17, 10.19, 10.21, 10.22, 10.24, 10.37, 10.38) so every substantive non-Extension group now has a ★★ rung; the chapter's
Critical thinking and synthesisgroup stays all ★★★ by design. -
Section-coverage notes refreshed in
exercises/07.ymlandexercises/11.ymlto reference the new exercises and reflect the chapter's actual coverage shape. -
Solutions for the new exercises added to the (instructor-only)
exercises/06-solutions.yml,08-solutions.yml,10-solutions.ymlfiles.instructor-solutions/_site/index.htmlre-rendered cleanly with no cross-reference warnings.
Surfaced by the QC-alignment audit:
- Ch 8 picks up Q11: the Mythbusters yawning case study (§ 8.4) — previously uncovered by any QC. Intro line updated from "Ten questions" → "Eleven questions."
- Ch 9 picks up Q11–Q12: the music-popularity activity (§ 9.2) and the IMDb case study (§ 9.6) — both anchored on the chapter's worked examples. Intro line updated from "Ten" → "Twelve."
- Ch 10 picks up Q11–Q12: partial-slope interpretation in the coffee model (§ 10.5) and the
infer::fit()bootstrap CI for partial slopes (§ 10.6) — the previously-thin multiple-regression material now has direct QC checks. Intro line updated from "Ten" → "Twelve."
Quick check stems and distractors must use only concepts the chapter has already introduced (per the long-standing in-repo rule). The lexicon scan caught five spots that violated this:
-
Ch 2 Q9 (faceting): distractor (d) "Creates a confidence interval per origin" → rewritten to "Sorts the data by
originlevel" —confidence intervalis a Ch 8 concept. -
Ch 5 LC (intercept term
$b_0$ ): option C "The standard error of the regression" → rewritten to "The slope of the regression line" —standard erroris a Ch 7 concept. -
Ch 7 Q1 (sampling distribution): distractor (d) "The probability that the null hypothesis is true" → rewritten to "How the population parameter varies across many possible populations" —
null hypothesisis a Ch 9 concept. -
Ch 1 Q3 (package re-loading): stem and option (d) referenced
filter()fromdplyr(a Ch 3 verb) → rewritten to useglimpse()(introduced in Ch 1). -
Ch 1 Q8 (
View()is read-only): answer key referenced "dplyr verbs (mutate(),filter(), etc.)" → rewritten to point forward via@sec-wranglingwithout naming the verbs.
The alt-text audit found 72 figures still lacking fig.alt= or with empty markdown image alt brackets after the initial migration pass. All resolved in this release:
- 65 new
fig.alt=descriptions added across foreword, preface, Ch 1, 2, 5, 11, App A, App B, and App C. Each describes the visual content of the figure (axes, shape, key features) rather than duplicating the human-readable caption — alt text andfig.cap=now consistently have different jobs across the book. - 3 markdown image alts filled in for the
data_ninja1.png,forcatspackage hex logo, andRninja.pngimages in App C. - Internal builder chunks (Ch 2
visualization-create-boxplot-components, Ch 10/11*-viz-*-altchunks) thatggsave()to disk without printing now carryfig.show='hide'so the alt-text audit doesn't flag them, and so accessibility tooling correctly understands no figure is rendered there.
- Stale doc reference: Ch 7's "you'll learn how to" callout pointed to
rep_sample_n(), but the chapter actually teaches the newerrep_slice_sample(). Updated to match.
Refactor and tighten the end-of-chapter exercise rollout, then sweep through it for forward-reference and difficulty-progression issues.
- Per-chapter exercise content (prompts, webr code, difficulty, group, section/subsection assignments) now lives exclusively in
exercises/NN.yml. Each chapter's## Exercisessection in its.qmdcallsrender_chapter_exercises(N); the matchingexercise-solutions/NN_ex.qmdcallsrender_solutions(N). No more drift between prompts in the chapter qmd and prompts in the solutions qmd — they read from the same YAML. - Coverage callout per chapter (a "Section coverage at a glance" table mapping book sections to exercise numbers) is now auto-generated by
render_coverage_callout(N). Consecutive exercise IDs collapse to en-dash ranges (e.g.,EX5.3–EX5.7) for readability. - Instructor-solutions HTML TOC fixed —
toc-depth: 3lets exercise group headers appear in the sidebar, and the per-chapter shortcode now lifts each chapter heading to the right level so the TOC isn't flat.
- Distractor scrubbing across Quick checks (Ch 4 first pass, then Ch 6, 8, 9, 10, 11) — rewrote multiple distractors that introduced forward-reference terminology and tightened wording on several stems.
- Forward-ref exercise moves: a handful of exercises that secretly required Ch 8+ material were promoted into each chapter's Extensions group (where the "deliberately introduces concepts beyond" framing is appropriate) rather than sitting in the main exercise list.
- R²/forward-ref cleanup in Chs 5 and 6: exercises mentioning R² migrated to Extensions (R² is properly introduced as a model-fit summary in Ch 10).
- EX 6.11 added to fill a parallel-slopes interpretation gap; small wording fixes across Ch 1, 3, 5, 6.
The accessibility complement to the Quarto port, plus the wave of migration-era bug fixes that surfaced as the build settled.
- All 150 figure chunks that existed at the time of the Quarto migration received dedicated
fig.altattributes describing each figure's visual content for screen-reader users — distinct from (and richer than) the human-readablefig.cap=. (The remaining ~70 figures get their alt text in 2.7.0's accessibility completion pass.)
- Added names to all chunks with the help of GitHub Copilot.
- Updated Posit cheatsheet links and screenshots to latest versions from https://rstudio.github.io/cheatsheets/.
- Added Learning Check solutions to the Appendix online (now also collapsibly inline in some chapters).
- Updated LC10.7.
- Deleted the
echo=FALSEthat was hiding the Chapter 11 Needed Packages. - Fixed a typo flagged by @Bmmju regarding 142 countries in Subsection 5.2.1 that was hard-coded — corrected to 188.
- Fixed another hard-coded typo flagged by @segre-ecophysiology-lab on the number of airlines in the Chapter 3 Learning Checks (fixed to 14 instead of 16).
- Fixed the typo of "95%" instead of "90%" in the interpretation of Subsection 9.4.2 flagged by @omian.
- Added
GGallyto the "Versions of R packages used" in the Preface (missing prior to publication of the Second Edition). - Replaced bookdown references in the Preface's "About this book" section with Quarto.
- Fixed code formatting in Tables 2.4 and 3.x (the chapter-end summary tables): markdown backticks in CSV-loaded cells were rendering as literal characters instead of inline code; cells now pre-process backticks into
<code>tags so verbs likegeom_point()andfilter()render correctly (and the newcode-linksetting hyperlinks them to package docs). - Fixed cheatsheet pipe rows (
|>) in Chapters 3, 10, 11 that were rendering as literal\|>due to markdown table-cell escaping inside backticks. - Normalized fenced-div opens to
::: {.learncheck}(with a space) across all chapters and appendices. The no-space form:::{.learncheck}is valid Pandoc but trips Quarto's lua filter, which would render the opening fence as literal text and emit a "problem with a fenced div" warning. - Inserted a missing blank line between a math display (
$$ … $$) and the immediately following::: {.learncheck}fence in Chapter 7; without the separator, Pandoc treated the fence as part of the preceding block and the closing:::would render as literal text under the Quick checks section.
- Roughly 320 new end-of-chapter exercises placed between Quick checks and Conclusion in every numbered chapter — ~30–35 per chapter for the substantive chapters (2–10), and smaller capstone sets for chapters 1 and 11. Each exercise carries a difficulty marker (★ warm-up, ★★ standard, ★★★ critical thinking).
- Five new exercise datasets, scaffolded gradually so packages and concepts accumulate naturally:
olympic_athletes/medal_table/editionsfrom theolympicAthletespackage — introduced in chapter 1, used throughout chapters 2, 3, 5, 8, 9, 10, 11.episodesfrom thestevespackage — Rick Steves' Europe (2000–2025); introduced in chapter 3.bob_rossfromfivethirtyeight(already CRAN) — used as the chapter 4 Tidy Data pilot dataset and revisited in chapters 8 and 9.planetsandstarsfrom theexoplanetdatapackage — introduced in chapter 6 and reused in 7, 10, 11.volcanoes/eruptions/eventsfrom thevolcanoespackage — introduced in chapter 7 and reused in 8, 9, 11.
- Inline WebR sandboxes beneath each code-needing exercise — same
{webr-r}mechanism as the chapter examples — with reasoning-only prompts left as plain text so the Run Code button only appears where it makes sense. - Solutions are instructor-only and not deployed alongside the public book. Per-chapter solution content lives in
exercise-solutions/NN_ex.qmd(mirroring thelc-answers/pattern) and is assembled into a self-contained HTML by a separate Quarto project atinstructor-solutions/. Each chapter's solutions section opens with a section coverage table mapping book sections to exercise numbers, and each entry shows a foldable show question callout above an always-visible Solution with a plain-text section reference. - CRAN/GitHub install toggle in
R/setup_exercise_packages.R— a singlefrom_githubflag per package. When any of the four GitHub-only packages reaches CRAN, flip its flag toFALSEand the next build pulls from CRAN instead.DESCRIPTIONhas matchingImports:andRemotes:entries so CI can install them either way. - Chapter 1 picks up a small "Looking ahead to end-of-chapter exercises" subsection that walks new readers through installing the first GitHub-only package (
olympicAthletes) withremotes::install_github()and previews the four other datasets they'll meet.
- Quick check quizzes — ten multiple-choice questions per chapter with collapsible answers, placed right before each Conclusion. Wrong-answer distractors deliberately reflect common student misconceptions (e.g.,
aes(constant)in Ch 2;==vs=in Ch 3; "95% probability the parameter is in this CI" in Ch 8; the multiple-testing problem in Ch 9), and each answer block briefly explains why each tempting wrong option is wrong. - WebR-runnable code cells — pilot in Chapters 2, 3, 4, and Appendix B. Click Run Code to execute R in your browser without installing anything; edit and re-run to experiment. Cells live inside collapsible "Try it interactively" callouts so the WebR runtime only loads when a reader actively expands one.
Substantive pedagogical scaffolding plus visual/navigation polish that the Quarto port made cheap to add.
- Learning objectives at the top of each of the 11 main chapters — Bloom-style "by the end of this chapter, you'll be able to…" lists.
- "Common mistake" callouts at predictable trouble spots:
aes()vs setting (Ch 2), thena.rm = TRUEreflex (Ch 3), correlation ≠ causation (Ch 5), the three distributions students confuse (Ch 7), the "95% probability the parameter is in this interval" misinterpretation (Ch 8), and the p-value as P(H₀ true) trap (Ch 9). - Per-chapter cheatsheets — compact reference tables of the verbs/functions introduced in each chapter, in a dedicated callout.
- Glossary appendix — alphabetized definitions of ~25 stats / data-science terms (sampling distribution, p-value, LINE conditions, …), each linking back to the chapter that develops the concept.
- New "Random sampling vs. random assignment" subsection at the end of Chapter 7, with a 2×2 summary table mapping the four study-design quadrants (random sample / random assignment, with/without each) to what kind of conclusion each design supports — and explicitly placing this book's example datasets within that grid.
- Dark mode + lightbox — sun/moon toggle in the navbar; click any figure to enlarge in a modal. Custom
.learncheck/.announcement/.reviewstyles have dark-aware variants. - Hyperlinked code — function names in code blocks now link to their package documentation (Quarto's
code-link: true).
The mechanical bookdown→Quarto conversion plus the deploy/CI infrastructure that supports it. No new chapter content in this release — all pedagogy additions arrive in subsequent releases. PDF/Krantz support is intentionally deferred; this release is HTML-only.
- All chapter source files renamed
.Rmd → .qmd._bookdown.ymland_output.ymlreplaced with a single_quarto.yml. - All bookdown cross-reference syntax (
\@ref(fig:x),\@ref(tab:x), section refs) converted to Quarto's@fig-x/@tbl-x/@sec-x. Chunk labels renamed accordingly. {block, type="learncheck"}paired blocks merged into single:::{.learncheck}fenced divs (one cohesive callout per Learning Check).- CI workflow now uses
quarto-actionsand caches.quarto/_freezefor fast incremental builds. - Cross-chapter R state (
version,dev_version,needed_CRAN_pkgs, helper functions) moved toR/image_functions.R, sourced by every chapter's auto-prependedsetup-initchunk (Quarto runs each chapter in its own R session).
- The bookdown source remains canonical on the
v2branch; the Quarto build is published to thev2-publishbranch and currently lives on thev2-quarto-htmlbranch. Existing reader URLs are preserved. _quarto.ymlrepo-actions: [edit, source, issue]enables per-page edit/source/issue links in the navbar.R/post-render-cleanup.shpost-render hook keeps the working tree tidy of macOS Cocoa render artifacts._tools/convert_bookdown.pland_tools/fix-chapter-refs.plpreserved as the migration tooling for future reference.quarto-publish.ymlnow pre-installs the four GitHub-only exercise packages withremotes::install_github()beforesetup-renv@v2runs, sorenv::restore()finds them already present and skips them — working around resolution failures on those entries in the lockfile.
-
Created https://moderndive.com/v2/ website to host the Second Edition (and later v2 and beyond) content
-
Removed previous data sets
promotions(Chapter 9) andevals(Chapters 5, 6, and 10) and replaced withun_member_states_2024andspotify_by_genreinstead -
Replaced
pennieswithalmonds_bowlin Chapter 7 -
Moved some sections around in Chapters 7 and 10 to improve readability
-
Moved model selection to Chapter 10 instead of Chapter 6
-
Added
coffee_qualityandold_faithful_2024examples to Chapter 10 -
Improved theory-based discussions in Chapters 8, 10, and 11
-
Added use of
fit()function for simulation-based inference with multiple linear regression -
Added
inferpackage withfit()to Chapter 11 to discuss inference for regression -
Added content in the Appendices
-
Used base-pipe
|>instead of%>%in all code chunks since those are in other updates. Some inline functions like"*"()were kept using%>%since they are more readable than converting to the base-pipe functionality. -
Addressed the warning message explicitly for
group_by()in text and fixindex.Rmdto removeoptions(dplyr.summarise.inform = FALSE) -
Added
relocate()to end of Chapter 3 -
Added
envoy_flightsandearly_january_2023_weatherto{moderndive}package -
Explained that
{nycflights23}is an updated version of{nycflights13}using the{anyflights}package -
Updated code and discussion throughout the book to use
{nycflights23}instead of{nycflights13} -
Chapter 2 Data Visualization: Remove soft introduction to
%>%operator (from Ch 3 Data Wrangling) since this only confused readers. Instead we now use a preparedalaska_flightsandearly_january_weatherdata frames frommoderndiveversion 0.5.3 -
Chapter 6 Multiple Regression: Per @kmkinnaird's suggestion, we split "6.3.1 Model selection" into:
- "6.3.1 Model selection using visualizations"
- Added "6.3.2 Model selection using R-squared"
-
Chapter 7 Sampling: Per @kmkinnaird's suggestion, refactored as follows
- "7.3.1 Terminology & notation": clustered definitions according to theme and connected back to sampling exercises
- "7.3.2 Statistical definitions":
- Moved "7.5.2 Central Limit Theorem" to its own section to make it more prominent and not an after-thought
- Created a new "7.6.2 Theory-based standard errors" which split "8.7.2 Theory-based confidence intervals" into two parts and moved the earlier part to Chapter 7 Sampling. That way all 4 statistical inference chapters (Ch 7-11) each of their own "theory-based X" subsection at the end bridging the gap between simulation based and traditional methods.
- Typo fixes and clarifying wording tweaks
- With a big assist from @mariumtapal, we cleaned and refactored all R Markdown code to make it easier for future bookdown users to understand. However all code seen by readers of the print edition has been left intact.
- Appendix C (online only):
- Renamed from "Reach for the Stars" to "Tips and Tricks".
- Added C.1 section on most common data wrangling questions we've encountered, mostly written by @smetzer180
- Version 1.0.0 corresponds to our CRC Press print edition.
- Changed word in title of book from "moderndive" to "ModernDive" for consistency with hex sticker.
- Added Foreword by Kelly S. McConville. Thanks, @mcconvil!
- Fixed various typos throughout the book and tried to make language consistent. For example, using "data sets" instead of "datasets" or "data-sets".
- Switched from
gather()andspread()withtidyrtopivot_long()andpivot_wide()following this tidyverse article - Added
geom_parallel_slopes()user-defined geom extension toggplot2
- Changed chapter numbers. Chapter "1. Introduction" is now "Preface", thus all Chapter numbers decreased by one.
- Moved discussions on normal distribution (Ch on sampling) and log-transformations (Ch on tell your data story) to Appendix A "Statistical Background"
- Updated images used in book
- Did a full scan of the book for typos
- Created greyscale versions of many images for the CRC Press printed version
We're only a few cosmetic edits away from v1.0.0, which will correspond to our print edition with CRC Press!
Completed major re-organization and clean-up of Chapters 9-11 using the infer package for "tidy and transparent" statistcal inference.
- Chapter 9: Bootstrapping & confidence intervals
- Tactile exercise of sampling 50 pennies from bank and resampling from this sample.
- Added sections on
- "Interpreting confidence intervals", in particular determinants of CI width.
- "Theory-based confidence intervals" using formula for SE of p-hat, thereby bridging gap between simulation and theory-based methods.
- Chapter 10: Hypothesis testing
- Added
promotionsexample on gender discrimination in promotions at a bank. Data source:openintro::gender.discrimination - Added section on "Theory-based hypothesis tests" using t-test, thereby bridging gap between simulation and theory-based methods.
- Added
- Chapter 11: Inference for regression.
- Discussion on LINE conditions for inference. In particular using
moderndive::get_regression_points()wrapper function tobroom::augment()so that novices can do their own residual analyses.
- Discussion on LINE conditions for inference. In particular using
- Chapter 7: Multiple regression
- Added Section 7.3.1 on model selection: choosing between "interaction" and "parallel slopes" models
- Chapter 8: Sampling
- Added Section 8.5.3 with more in-depth discussion of normal distribution
- Chapter 12: Renamed to "Tell your story with data"
- "Data wrangling" chapter now comes after "Tidy data" chapter.
- Improved explanations and examples of
geom_histogram(),geom_boxplot(), and "tidy" data - Moving residual analysis from regression Chapters 6 & 7 to Chap 11: Inference for regression
- Reorganized Chap 8 on Sampling
- All learning check solutions now in Appendix D
- PDF build re-added (still a work-in-progress)
- Changed title
- From: "Statistical Inference via Data Science in R"
- To: "Statistical Inference via Data Science: A moderndive into R and the tidyverse"
- Chapter 2 - Getting Started
- Added subsection 2.2.3 "Errors, warnings, and messages" by @andrewheiss
- Chapter 3 - Data visualization:
- Added simpler introductory
geom_histogram()andgeom_boxplot()examples - Started downweighting the amount of data wrangling previews included in this chapter, in particular
join. - Cleaned up conclusion section
- Added cheatsheet
- Added simpler introductory
- Switched order of "Chap 4 Tidy Data" and "Chap 5 Data Wrangling": Data Wrangling now comes first
- Chapter 4 - Data wrangling:
- Added cheatsheet
- Chapter 5 - Renamed to "Importing and tidy data"
- Reordered sections: importing then tidying
- Added
fivethirtyeight::drinksexample of "hitting the non-tidy wall", then usingtidyr::gather() - Made Guatemala democracy score a case study.
- Added discussion on what
tidyversepackage is. - Moved discussion on normal forms to Ch4: Data Wrangling - joins.
- Moved discussion on identification vs measurement variables to Ch2: Getting started with data.
- Chapter 6 - Basic regression:
- Moved residual analysis to Chapter 11
- Chapter 7 - Multiple regression:
- Moved residual analysis to Chapter 11
- Chapter 8 - Sampling: Major refactoring of presentation/exposition; see below
- Chapter 11 - Inference for regression:
- Moved residual analysis from Chapter 6 & 7 here
- Moved all Learning Check solutions to Appendix D
Old chapter structure:
- Introduction to sampling a) Concepts related to sampling b) Inference via sampling
- Tactile sampling simulation a) Using the shovel once b) Using the shovel 33 times
- Virtual sampling simulation a) Using the shovel once b) Using shovel 33 times c) Using shovel 1000 times d) Using different shovels
- In real-life sampling: Polls
- Conclusion a) Central Limit Theorem b) What’s to come? c) Script of R code
New chapter structure:
- Activity: Sampling from a bowl a) Question: What proportion of this bowl is red? b) Using shovel once c) Using shovel 33 times
- Computer simulation: a) What is a simulation? We just did a "tactile" one by hand, now let's do one using the the computer b) Using shovel once c) Using shovel 33 times d) Using shovel 1000 times e) Using different shovels
- Goal: Study fluctuations due to sampling variation a) You probably already knew: Bigger sample size means "better" guess. b) Comparing shovels: Role of sample size
- Framework: Sampling a) Terminology for sampling (population, sample, point estimate, etc) b) Statistical concepts: sampling distribution and standard error c) Computer's random number generator
- Interpretation: a) Visual display of differences
- Case study: Obama poll
- Big picture: a) Table of inferential scenarios: Add bowl and obama poll (both p) b) Why does this work? Theoretial result: CLT c) There's a formula for that: SE formula that has sqrt(n) at the bottom d) Appendix: Normal distribution discuss
- The
inferpackage is ready for prime-time! Thus we made a first pass at incorporating it into the book in Chapters 9 and 10 on confidence intervals and hypothesis testing! - Chapter 12 on "Thinking with Data" now includes a case study using the Seattle house prices dataset on Kaggle.com. Chapters 3 and 4 from new "Modeling with Data in the Tidyverse" DataCamp course by Albert Y. Kim are based on this analysis!
- Speaking of DataCamp, we point readers to various DataCamp courses that directly align with various chapters in the book!
- We significantly cleaned up Chapter 8 on sampling! In particular: adding a 2013 Obama approval rating poll example to tie in with our sampling bowl tactile and virtual simulations and making it very clear that ultimately we are performing statistical inference via sampling.
- Introduction: Added section on correspondence of chapters to various DataCamp courses. Furthermore, links to relevant DataCamp course are included at the outset of each chapter.
- Chapter 3 - Data visualization:
- Added simplified
geom_jitter()example - More explanations for how whiskers and outliers are constructed in
geom_boxplots - Added summary of table of all 5 named graphs
- Added simplified
- Chapter 4 - Tidy data:
- Added section on importing Excel data via RStudio
- Added example of tidy vs non-tidy:
fivethirtyeight::drinks
- Chapter 5 - Data wrangling:
- Added computing available seat miles data wrangling case study
- Abandoned "5 Main Verbs" 5MV notion
- Added
_join()andgroup_by()multiple variables
- Chapter 6 - Basic regression:
- Clarified explanations of indicator/dummy variables when using categorical variable in regression.
- Expanded "Correlation is not necessarily causation" subsection with example of "does sleeping with shoes on cause headaches?" including causal diagram
- Introduced concept of a "wrapper function" when introducing
moderndive::get_regression_table()function - Replaced all
base::summary()withskimr::skim()for quick numerical summaries
- Chapter 7 - Multiple regression:
- Changed all "everything else being equal" interpretation statements with "taking into account/controlling for all other variables in our model"
- Chapter 8 - Sampling:
- Significantly cleaned up sampling terminology and definitions and made more clear that we are sampling for inference
- Cleaned up section and subsection structure to be much cleaner:
- Tactile sampling simulation
- Virtual sampling simulation
- In real-life sampling: Introduced example of 2013 Obama approval rating poll and then tie everything with sampling bowl.
- Major overhaul: Chapter 9 - Confidence intervals
inferpackage now being ready for prime-time, we made first pass at incorporation into book.
- Major overhaul: Chapter 10 - Hypothesis testing
inferpackage now being ready for prime-time, we made first pass at incorporation into book.- Added discussion on Allan Downey's "There is only one test" ideas
- Chapter 11 - Inference for Regression
- Added a simple linear regression example using the
inferpackage
- Added a simple linear regression example using the
- Major overhaul: Chapter 12 - Thinking with data
- Added case study of Seattle house prices dataset from Kaggle, which is now available in
house_pricesdataframe inmoderndivepackage.- Chapters 3 and 4 from new "Modeling with Data in the Tidyverse" DataCamp course are based on this analysis
- Includes a discussion on the importance of
log10-transformations - Introduces modeling/regression for prediction: predicting house prices
- Laid outline for "effective data storytelling" using
fivethirtyeightdata and added one small example using US births data - At the beginning of chapter, we now come full circle and revisit the discussion on the ModernDive flowchart in the introduction.
- Added case study of Seattle house prices dataset from Kaggle, which is now available in
- Updated
moderndivepackage on CRAN to 0.2.0. SeeNEWS.md
- Reorganized chapter sequencing according to flowchart at top of Section 1.1
- Chapter 2 - Getting Started: Added more explanation on R packages, including analogy for
install.packages()andlibrary()(akin to downloading apps onto phone) - Added "Data Modeling" portion to book
- Chapter 6 - Basic regression: one numerical explanatory variable, correlation, one categorical explanatory variable)
- Chapter 7 - Multiple regression: two numerical explanatory variables, one numerical and one categorical, interaction effects, Simpson's Paradox
- Uses new
moderndivepackage, which includesget_regression_table()andget_regression_points()wrapper functions to simplify outputting of clean regression tables and observed/fitted values + residuals
- Added "statistical inference" portion to book
- Added Chapter 8 - Sampling (still under construction) using sampling bowl
- Chapters 9 and 10 on confidence intervals and hypothesis testing have not yet been updated, as we were awaiting the now launched package:
infer: A tidyverse-friendly R package fo statistical inference - Added Chapter 11 - Inference for regression (still under construction), where we'll revisit the regression models fit in Chapters 6 & 7
- Development version of book now available at https://moderndive.netlify.com/; deployed via travis-ci + netlify.
- Added wide ModernDive logo to top of each chapter and
logosfolder - Added favicon (icon in browser tab)
- Moved home GitHub repository from https://github.com/ismayc/moderndiver-book/ to https://github.com/moderndive/moderndive_book
- Incorporated feedback from consultations with Prof. Jude Weinstein Jones, cognitive psychological scientist and co-founder of The Learning Scientists.
- Restructured/revamped chapters
- Chapter 1: Introduction
- Friendlier introduction targeted to students is first thing users see. Followed then by introduction for instructors, ways to connect/contribute, and technical details.
- Added links to example student projects from two courses that have previously used ModernDive:
- Middlebury College MATH 116 Introduction to Statistical and Data Sciences using student collected data.
- Pacific University SOC 301 Social Statistics using data from the fivethirtyeight R package
- Chapter 2: Getting Started New chapter added meant for new R users/coders, including
- Discussions on R vs RStudio and how to install both (with support videos)
- A "How do I code in R?" section with links to DataCamp.com courses that covers the console, data types, vectors, factors, data frames, boolean operators, functions etc
- Thorough discussion on R packages
- An end-to-end starter example analysis of the data frames in the
nycflights13package using the console,View(),glimpse()etc.
- Chapter 3: Data Visualization via
ggplot2now first non-intro chapter.- Replaced Menard's "Napolean's March on Moscow" with Hans Rosling's (RIP) "Gapminder" plots as introductory example to Grammar of Graphics.
- Added
geom_col()for making barcharts when data is pre-tabulated, instead of usinggeom_bar(stat="identity")
- Chapter 4: Tidy Data via
tidyrbumped back. Added sections on converting from wide to long/tidy format and importing CSV's - Chapter 5: Data
ManipulationWrangling viadplyr - Chapter 6: Data Modeling using Regression via
broombumped up from end of book to here given its pedagogical importance, added notes on viewing regression in a prediction framework. - Chapter 7-9: Sampling, Hypothesis Testing, Confidence Intervals Mostly unchanged for now; see pending changes section below.
- Chapter 1: Introduction
- Book is now hosted on ModernDive.com
- Development version now on original ModernDive site https://ismayc.github.io/moderndiver-book/
- Added links to digital copies and source code of all past versions of ModernDive in Chapter 1.
- Cut build/compilation time of book from ~20 minutes to ~1 minute
- Disabled gitbook PDF output
- Chapter 6: Data Modeling using Regression via
broom- Better treatment of experimental design and its effect on bias/causation than currently exists in chapter.
- Examples of regression with categorical predictors with 3 or more levels.
- Multivariate regression, in particular the following predictor scenarios: 2 numerical, 2 categorical, and 1 numerical + 1 categorical
- Interaction effects
- Chapter 7-9: Sampling, Hypothesis Testing, Confidence Intervals have largely not been updated, pending developments of
infer: A tidyverse-friendly R package fo statistical inference
- Attempting to fix Shiny app in Figure 6.2 appearing as white box in published site noted here
- Reverted to using screenshot with link instead
- Updated link to
dplyrcheatsheet andggplot2cheatsheet - Began adding DataCamp chapters as Review Questions to the end of Chapters 3 and 4 (More to come)
- Updated link to MailChimp
- Fixed wording in a few Ch 3 Learning Checks
- Converted last updated in index.Rmd to inline instead of R chunk
- Fixed edit link to point to moderndive-book GitHub repo instead of moderndive-source repo
- Fixed broken links to script files at the end of Chapters 4-9
- Added
purl=FALSEto chunks that do not contain useful code to the reader - Attempting to fix Shiny app in Figure 6.2 appearing as white box in published site noted here
- Fixed the problems of chapter cross-references not working by removing the backticks in chapter names
- Issue created on
bookdownhere
- Issue created on
- Looked for typos throughout all chapters
- Added coggle diagrams to Chapter 4 and Appendix B
- Followed the same format of having a Conclusion section at the end of each chapter
- Fixed
$T$ distribution plot with histogram in Chapter 7- May be weird issue with
cache = TRUEthat incorrectly plotted values on 1/10^th^ the correct scale - Will need to keep an eye on it going forward
- May be weird issue with
- Fixed typo on Reach for the Stars chapter name
- Fiat Lux!
- Basic chapter structure in place
- First pass at II Inference section (Chapters 6-9) complete
- First revisions of I Data Exploration (Chapters 3-5) nearly complete