This companion to the second edition of Advanced R works through every one of that book’s 284 exercises, giving readers a way to check their understanding as they study how R works under the hood. Malte Grosser and Henning Bumann wrote the solutions, and Hadley Wickham, the author of Advanced R, reviewed each chapter with corrections, suggestions, and occasionally his own answers until every exercise was approved.

The authors came to R from mathematics and statistics rather than software engineering, and the solutions reflect that path. They favor clean, idiomatic code over lengthy prose, with short explanations that supply context, discuss implementation details, or connect an exercise to everyday R programming. The book follows the structure of Advanced R so the two are easy to read side by side, and the authors recommend trying each exercise yourself before turning to their answer.

The solutions span all five parts of Advanced R:

  • Foundations, including names and values, vectors, subsetting, functions, environments, and conditions
  • Functional programming with functionals, function factories, and function operators
  • Object-oriented programming with S3, R6, and S4
  • Metaprogramming, from expressions and quasiquotation to evaluation and translating R code into HTML and LaTeX
  • Techniques for measuring and improving performance, including rewriting R code in C++

The full text is free to read online, and the authors donate half of their royalties to R-Ladies.