Review of ‘Advanced R’ by Hadley Wickham

24 May 2015

Executive summary

Surprisingly good.

And it’s not like my expectations were especially low.


There are 20 chapters.  I mostly like the chapters and their order.

Hadley breaks the 20 chapters into 4 parts.  He’s wrong.  Figure 1 illustrates the correct way to formulate parts.

Figure 1: Chapters and Parts of Advanced R. advanced_R_table_of_contents


Introductory R

There are by now lots of introductions to R.  There’s even an R for Dummies.

The introduction here is clean and serviceable.  If you are an experienced programmer learning R, these chapters will provide you with most of the basics.


Chapter 5 on code style is a bit of fluff that insulates the introductory material from the more advanced part.  I hope most people can just about cope with there being an extra space or new line compared to their preference.

However, the chapter does talk about one thing that I think is very important: consistent naming style.  Consistent naming conserves a lot of energy for users — it allows them to think about what they are doing rather than trying to remember trivia.  I believe my personal best for continuous consistent naming in R is 4.3 hours of coding time.  In R it’s hard.

Language R

In which the balance of the universe is partially restored.

There are lots of places that talk about what a chaotic mess R is.  A book-length dose of venom is The R Inferno.

These chapters, in contrast, show the elegance, the flexibility, the power of the R language.  This is the mesmerizing part of the book.

Both views are valid: the mess in on the surface, the beauty is deeper.

Working with R

Useful.  But it includes the word “work” so it can’t be all good.

Favorite sentences

R doesn’t protect you from yourself: you can easily shoot yourself in the foot.  As long as you don’t aim the gun at your foot and pull the trigger, you won’t have a problem.

On speed:

R was purposely designed to make data analysis and statistics easier for you to do.  It was not designed to make life easier for your computer.  While R is slow compared to other programming languages, for most purposes, it’s fast enough.

On object orientation:

S3 is informal and ad hoc, but it has a certain elegance in its minimalism: you can’t take away any part of it and still have a useful OO system.


Appendix R

Here is the code that created Figure 1:

P.advanced_R_table_of_contents <- 
 function (filename = "advanced_R_table_of_contents.png", seed=18) 
  if(length(filename)) {
    png(file=filename, width=512, height=700)
  advR.chap <- c('Introduction', 'Data structures', 'Subsetting', 'Vocabulary',
                 'Style guide', 'Functions', 'OO field guide', 'Environments', 
                 'Debugging, condition handling, and defensive programming', 
                 'Functional programming', 'Functionals', 'Function operators',
                 'Non-standard evaluation', 'Expressions', 'Domain specific languages',
                 'Performance', 'Optimising code', 'Memory', 
                 'High performance functions with Rcpp', "R's C interface")
  advR.chap[9] <- "Debugging, [...]"
  plot.window(xlim=c(0,4), ylim=c(21,0))
  hl <- 1.7
  pl <- 2.3
  if(length(seed) && ! set.seed(seed)

  text(c(.5, 2, 3.5), .5, c("Hadley part", "Chapter", "Pat part"), font=2)
  rect(0, 1.5, hl, 9.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(0, 9.5, hl, 12.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(0, 12.5, hl, 15.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(0, 15.5, hl, 20.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(pl, 1.5, 4, 4.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(pl, 5.5, 4, 14.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  rect(pl, 14.5, 4, 20.5,'rgb', as.list(runif(3, .8, 1))), border=NA)
  text(2, 1:20, advR.chap)
  text(hl/2, 5.5, "Foundations")
  text(hl/2, 11, "Functional\nprogramming")
  text(hl/2, 14, "Computing\non the\nlanguage")
  text(hl/2, 18, "Performance")
  text((4+pl)/2, 3, "Introductory\nR")
  text((4+pl)/2, 10, "Language\nR")
  text((4+pl)/2, 17.5, "Working with\nR")
  if(length(filename)) {

The part that may be of most interest is that the colors are randomly generated.  Not all colors are allowed — they can only go so dark.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

© Copyright - Burns Statistics