ABSTRACT

Advanced R helps you understand how R works at a fundamental level. It is designed for R programmers who want to deepen their understanding of the language, and programmers experienced in other languages who want to understand what makes R different and special.

This book will teach you the foundations of R; three fundamental programming paradigms (functional, object-oriented, and metaprogramming); and powerful techniques for debugging and optimising
your code.

By reading this book, you will learn:

  • The difference between an object and its name, and why the distinction is important
  • The important vector data structures, how they fit together, and how you can pull them apart using subsetting
  • The fine details of functions and environments
  • The condition system, which powers messages, warnings, and errors
  • The powerful functional programming paradigm, which can replace many for loops
  • The three most important OO systems: S3, S4, and R6
  • The tidy eval toolkit for metaprogramming, which allows you to manipulate code and control evaluation
  • Effective debugging techniques that you can deploy, regardless of how your code is run
  • How to find and remove performance bottlenecks

The second edition is a comprehensive update:

  • New foundational chapters: "Names and values," "Control flow," and "Conditions"
  • comprehensive coverage of object oriented programming with chapters on S3, S4, R6, and how to choose between them
  • Much deeper coverage of metaprogramming, including the new tidy evaluation framework
  • use of new package like rlang (https://rlang.r-lib.org), which provides a clean interface to low-level operations, and purr (https://purrr.tidyverse.org/) for functional programming
  • Use of color in code chunks and figures

    Hadley Wickham is Chief Scientist at RStudio, an Adjunct Professor at Stanford University and the University of Auckland, and a member of the R Foundation. He is the lead developer of the tidyverse, a collection of R packages, including ggplot2 and dplyr, designed to support data science. He is also the author of R for Data Science (with Garrett Grolemund), R Packages, and ggplot2: Elegant Graphics for Data Analysis.

chapter 1|12 pages

Introduction

part I|2 pages

Foundations

part |2 pages

Introduction

chapter 2|22 pages

Names and values

chapter 3|34 pages

Vectors

chapter 4|24 pages

Subsetting

chapter 5|10 pages

Control flow

chapter 6|36 pages

Functions

chapter 7|28 pages

Environments

chapter 8|32 pages

Conditions

part II|2 pages

Functional programming

part |4 pages

Introduction

chapter 9|38 pages

Functionals

chapter 10|24 pages

Function factories

chapter 11|12 pages

Function operators

part III|2 pages

Object-oriented programming

part |6 pages

Introduction

chapter 12|6 pages

Base types

chapter 13|28 pages

S3

chapter 14|16 pages

R6

chapter 15|22 pages

S4

chapter 16|8 pages

Trade-offs

part IV|2 pages

Metaprogramming

part |2 pages

Introduction

chapter 17|10 pages

Big picture

chapter 18|30 pages

Expressions

chapter 19|36 pages

Quasiquotation

chapter 20|30 pages

Evaluation

chapter 21|20 pages

Translating R code

part V|2 pages

Techniques

part |2 pages

Introduction

chapter 22|14 pages

Debugging

chapter 23|12 pages

Measuring performance

chapter 24|16 pages

Improving performance

chapter 25|30 pages

Rewriting R code in C++