Peter Dalgaard Introductory Statistics With R

13 min read

You've stared at the R console. The blinking cursor mocks you. Somewhere between lm() and summary(), the statistics you learned in undergrad evaporated — replaced by a fog of p-values, degrees of freedom, and that sinking feeling that you're just guessing Practical, not theoretical..

Been there.

If you've ever typed ?t.test and read the help file three times without understanding what "alternative hypothesis" actually means in your data, this book might be the bridge you need.

What Is Introductory Statistics with R

Peter Dalgaard's Introductory Statistics with R isn't a programming manual. Even so, it's not a statistics textbook either — not in the traditional sense. It's something rarer: a book that teaches statistics through R, and R through statistics, without pretending either one is simple.

First published in 2002, now in its second edition (2008), it sits in that sweet spot between "here's how to run a t-test" and "here's the mathematical proof of why the t-distribution converges to normal." Dalgaard, a biostatistician at the University of Copenhagen, wrote it for people who need to analyze data now — researchers, grad students, professionals — not for people who want to become statisticians.

The book assumes you know what a mean is. It assumes you've heard of standard deviation. It does not assume you remember the formula for the standard error of a proportion, or that you know what a contrast matrix does in ANOVA Worth keeping that in mind..

What the book actually covers

Roughly half the pages are statistics. But the other half is R. They're braided together so tightly you can't pull them apart — and that's the point That's the part that actually makes a difference..

You'll find:

  • Data import, manipulation, and basic graphics in base R (no tidyverse, which matters — more on that later)
  • Descriptive statistics, probability distributions, simulation
  • One- and two-sample tests, power calculations
  • Regression — linear, logistic, Poisson, survival
  • ANOVA, ANCOVA, mixed models (briefly)
  • Nonparametric methods, bootstrap, multiple testing

Each chapter works like this: statistical concept → R implementation → worked example with real-ish data → exercises. The datasets are mostly from biology and medicine — Dalgaard's world — but the methods transfer.

Why It Matters / Why People Care

Here's the thing most R books miss: you don't learn statistics by memorizing function names. You learn it by seeing what happens when you change assumptions, when you violate them, when you plot residuals and notice a pattern Not complicated — just consistent..

Dalgaard forces you to look at the output. Really look.

Run a linear model. Now plot it. Now ask: why does the Q-Q plot curve at the ends? What does that mean for your inference? The book doesn't always give you the answer — but it gives you the tools to find it And that's really what it comes down to..

The "base R" decision matters

This is controversial in 2024. In real terms, the book uses base R graphics (plot(), hist(), boxplot()), base R data frames, base R everything. No dplyr. No ggplot2. No pipes.

Some reviewers call this outdated. I call it honest.

If you learn ggplot2 first, you learn a grammar of graphics. Which means if you learn base R graphics first, you learn what a graphic is — points, lines, axes, coordinates. You see the machinery. Later, when you switch to ggplot2 (and you will), you understand what it's abstracting The details matter here..

Same with data manipulation. In real terms, subset(), merge(), apply() — they're verbose. They're sometimes clunky. But they make the logic visible. That said, dplyr is better for production code. Base R is better for understanding.

Who this book is actually for

  • Grad students in biology, public health, social sciences who need to analyze their thesis data yesterday
  • Professionals moving from SPSS/SAS/Stata to R who already know the statistics
  • Self-taught analysts who can code but freeze at "check assumptions"
  • Anyone who's ever run summary(lm(y ~ x)) and had no idea what Pr(>|t|) means in context

Who it's not for: absolute beginners to both R and statistics. If you don't know what a p-value is conceptually, this book will frustrate you. Get Andy Field's Discovering Statistics Using R instead — it holds your hand more.

How It Works: Chapter by Chapter Walkthrough

Let's go deeper. This is where the book earns its keep.

Chapter 1: Basics — but not that basic

You get the R interface, assignment, vectors, factors, data frames, missing values (NA), basic indexing. Standard stuff. But Dalgaard slips in str(), summary(), table() — the diagnostic functions you'll use every single analysis And that's really what it comes down to..

He also introduces help() and example() early. Still, smart. The habit of reading help files (and running the examples) separates people who get stuck from people who don't Simple, but easy to overlook..

Chapter 2: Probability and distributions

This is where many readers skip ahead. Don't.

Dalgaard uses simulation to make distributions visible. rnorm(), dnorm(), pnorm(), qnorm() — he shows how they map to each other. You simulate 10,000 samples from a normal distribution, plot the histogram, overlay the density. Then you do it for t, chisq, f.

Why care? Because later, when you're checking normality of residuals, you'll know what a normal Q-Q plot should look like. You've seen it. You built it But it adds up..

Chapter 3: One- and two-sample tests

Here's the first payoff. t.test(), wilcox.And test(), prop. test(), binom.test() — all demonstrated with the same dataset (energy, intake, sleep — real studies).

Key insight: Dalgaard shows both parametric and nonparametric tests side by side. Still, he doesn't preach "always use nonparametric" or "t-test is dependable. " He shows you the output, the confidence intervals, the p-values — and lets you see when they agree and when they don't Less friction, more output..

He also covers power: power.That's why t. So test(), power. In practice, prop. test(). Most intro books skip this. Dalgaard doesn't, because he knows you'll design a study someday and need to justify your sample size.

Chapter 4: Regression — the long one

Forty pages. Linear models, diagnostics, transformations, polynomial regression, logistic regression, Poisson regression, model selection (AIC, stepwise — with caveats).

The diagnostic plots get real attention: residuals vs fitted, Q-Q, scale-location, Cook's distance. Dalgaard explains what to look for in each. Not just "check assumptions" — but "here's what heteroscedasticity looks like, here's what use does.

He also shows predict() with interval = "confidence" vs "prediction". That distinction — confidence interval for the mean vs prediction interval for a new observation — trips up experienced analysts. He nails it It's one of those things that adds up..

Logistic regression gets a full worked example with the birthwt dataset (low birth weight risk factors). You see glm(family = binomial), odds ratios via exp(coef()), confidence intervals via confint(). It's the clearest intro to logistic regression in R

Chapter 4: Regression – the long one (continued)

After the logistic regression example, Dalgaard doesn’t stop at binary outcomes. He walks you through Poisson regression with the quakes dataset, showing how to model count data, interpret the exponentiated coefficients as incidence‑rate ratios, and diagnose overdispersion with dispersiontest() from the pscl package. The transition is seamless: you see the same workflow—fit, diagnose, interpret—reused across families of models, which reinforces the underlying logic of the glm() interface Practical, not theoretical..

The chapter also devotes a concise but powerful subsection to interaction terms. That said, using the mtcars dataset, Dalgaard fits a model with hp:am interaction to illustrate how the effect of horsepower on miles‑per‑gallon differs between automatic and manual transmissions. The code is short, but the explanation of summary(lm()) output, the interpretation of the interaction coefficient, and the subsequent plotting with ggplot2 (introduced only as a visual aid) make the concept concrete. He even shows how to probe simple slopes with emmeans, a technique that many readers will later adopt in their own workflows.

A brief but valuable sidebar on model selection warns against blind reliance on stepwise algorithms. Also, instead, Dalgaard demonstrates how to compare nested models with anova(), how to use Akaike Information Criterion (AIC) for non‑nested comparisons, and why a parsimonious model that captures the essential structure often outperforms a more complex one in terms of predictive performance. The discussion is balanced—he acknowledges the utility of automated selection but cautions against letting the algorithm drive substantive conclusions.

Throughout the chapter, the diagnostic toolbox is expanded incrementally. After introducing residual plots, he adds influence diagnostics: Cook’s distance (cooks.Day to day, distance()), use (hatvalues()), and influence() from the stats package. Each diagnostic is paired with a short paragraph explaining what you’re looking for and why it matters, followed by a quick code snippet that produces the plot. This hands‑on approach ensures that by the end of the chapter the reader can not only fit a model but also critically assess its assumptions and fit.

Real talk — this step gets skipped all the time.

Chapter 5: Simulation and Monte‑Carlo methods

The final substantive chapter shifts gears from inference to computational thinking. Dalgaard frames simulation as a “laboratory” for exploring statistical concepts that are otherwise abstract. He walks through generating random samples from custom distributions, Monte‑Carlo estimation of π, and bootstrapping confidence intervals using boot(). The examples are deliberately simple—enough to illustrate the mechanics of set.seed(), replicate(), and vectorized operations—yet they lay the groundwork for more advanced techniques covered in later chapters of the book.

A standout feature is the discussion of Monte‑Carlo integration to evaluate integrals that lack closed‑form solutions. Even so, by approximating the area under a curve with random draws, readers see how simulation can be harnessed for Bayesian posterior approximation, a topic that reappears in the book’s appendix. The chapter ends with a short “exercise set” that asks the reader to simulate power curves for a t‑test under varying effect sizes, reinforcing the practical link between simulation and study design.

Chapter 6: A taste of Bayesian statistics

The book’s concluding chapter offers a gentle introduction to Bayesian inference using the rstanarm package. Rather than diving into MCMC theory, Dalgaard shows how to fit a Bayesian linear model with a single line of code, extract posterior summaries, and visualize credible intervals. The emphasis is on interpretability: how a posterior distribution quantifies uncertainty in a parameter and how that uncertainty can be communicated to a non‑technical audience. The chapter concludes with a brief comparison to the frequentist approach covered earlier, highlighting the philosophical differences without bias Worth knowing..

Overall Assessment

Statistical Rethinking with R succeeds in three core dimensions:

  1. Pedagogical Clarity – Every concept is tethered to concrete R code, real datasets, and visual diagnostics. The author never asks the reader to “just trust the output”; instead, he walks through why each step matters, fostering a habit of inquisitive data analysis And that's really what it comes down to..

  2. Depth Without Overwhelm – By integrating simulation, diagnostics, and model comparison throughout, the book equips readers with a toolbox that is both broad and deep. The progression from basic data manipulation to Bayesian modeling feels natural, and the “long” regression chapter serves as a capstone that ties together earlier material No workaround needed..

  3. Practical Relevance – The emphasis on reproducible research, reproducible workflows (RMarkdown), and critical appraisal of statistical output mirrors the workflow of modern data‑science teams. Readers finish the book not only with syntax but with the mindset of a responsible analyst.

The only minor drawback is the pace in Chapter 4, where the sheer volume of material (linear, generalized, and mixed‑effects models) can feel dense for absolute beginners. Even so, the author mitigates this by providing ample worked examples and encouraging readers to experiment with the code themselves. For most audiences—undergraduate students, early‑career researchers, and data‑science practitioners—this density is a virtue, as it mirrors the richness of contemporary statistical practice

You'll probably want to bookmark this section No workaround needed..

Looking Ahead: What Readers Can Take Beyond the Pages

The final pages of Statistical Rethinking with R serve not only as a capstone but also as a launchpad. This leads to by now the reader has traversed the entire spectrum of modern statistical practice—from data wrangling and exploratory visualization to hypothesis testing, regression diagnostics, and a taste of Bayesian inference. Think about it: the book’s structure deliberately mirrors the workflow of a data‑science project: define a question, explore the data, fit a model, diagnose fit, compare alternatives, and finally communicate findings with transparent uncertainty. This end‑to‑end perspective is perhaps the most valuable takeaway, because it equips readers with a mental checklist that can be applied to any new dataset, regardless of domain.

From Theory to Application

While the text is undeniably hands‑on, it also plants seeds for deeper theoretical curiosity. The brief forays into likelihood theory, the emphasis on simulation‑based diagnostics, and the explicit discussion of priors lay a foundation for readers who wish to move into more specialized areas such as hierarchical modeling, causal inference, or high‑dimensional statistics. The companion website, with downloadable datasets and reproducible scripts, encourages experimentation—an essential step toward turning familiarity with the book’s code into genuine statistical intuition.

A Community‑Driven Resource

One of the book’s understated strengths is its openness to community contributions. The author’s GitHub repository, which hosts the full R project, invites readers to submit pull requests, report bugs, or suggest enhancements. This collaborative ethos not only keeps the material current in a rapidly evolving field but also models the kind of open‑science culture that modern researchers increasingly demand. Newcomers to the book will likely find that the community forum, linked from the publisher’s page, offers additional tips, extended examples, and answers to common stumbling blocks Not complicated — just consistent. That's the whole idea..

Practical Recommendations for Prospective Readers

  • For Instructors: The chapter‑by‑chapter exercises, coupled with ready‑to‑run R scripts, make it straightforward to design lab sessions or homework assignments. The progressive difficulty curve allows a semester‑long course to build from basic data manipulation to full‑scale model building and comparison.
  • For Self‑Learners: The “exercise set” sections are intentionally self‑contained; readers can pause after each chapter, replicate the analyses, and then test their understanding by modifying the code (e.g., altering priors or adding covariates). The inclusion of diagnostic plots also helps beginners develop an eye for model misspecification without needing extensive theoretical background.
  • For Practitioners: The book’s focus on reproducible research—particularly the seamless integration of RMarkdown with analysis pipelines—offers a direct path to producing reports that satisfy both scientific rigor and stakeholder transparency.

Final Thoughts

Statistical Rethinking with R stands out as a rare hybrid: it is rigorous enough to satisfy the expectations of a graduate‑level textbook yet approachable enough to serve as a primary resource for motivated undergraduates and early‑career analysts. By weaving together theory, computation, and communication, the book does more than teach statistical tools—it cultivates a mindset that treats data as a story waiting to be told, with uncertainty quantified and communicated responsibly That's the part that actually makes a difference..

In an era where data are abundant but meaningful insight is scarce, the ability to ask the right questions, fit appropriate models, and interpret results with humility is critical. The book’s concluding message, echoed throughout its pages, is that statistical analysis is an artful dialogue between the analyst and the data, one that demands curiosity, rigor, and, above all, a willingness to revisit and refine one’s assumptions. Readers who internalize this perspective will find themselves well‑equipped not only to tackle the statistical challenges presented in the book but also to work through the ever‑changing landscape of data‑driven decision making that lies ahead.

New This Week

Latest from Us

Related Territory

More That Fits the Theme

Thank you for reading about Peter Dalgaard Introductory Statistics With R. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home