Some quibbles about “The R Book” by Michael Crawley

[This article was first published on Portfolio Probe » R language, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A friend recently bought The R Book and I said I would tell him of problems that I’ve noticed with it.  You can eavesdrop.

Page 4

The word “library” is used instead of “package”.  This (common)  error substantially raises the blood pressure of some people — probably to an unwarranted extent.

An R package is a group of functions, data and their documentation.  These are the things that are in repositories like CRAN (where there are over two thousand packages).  A package is installed onto your machine into a library.

You are unlikely to call a book a library; don’t call a package a library.

Part of the problem is that packages are attached with the library function:

> library(fortunes)

That is why some instructions have you do the same thing via:

> require(fortunes)

Some of the people whose blood pressure is abnormally raised by seeing this mistake are very important to R, so please get this right.

Page 11

An example value is:

3.9+4.5i

that is, a complex number.  This is in the chapter called “Essentials of the R Language”.  I’ve been using R and a language not unlike R for a quarter century.  The only time I recall using complex numbers is when documenting them.  Complex numbers don’t match my definition of “essential”.

There is a certain amount of irony for a 600-word blog post to take n lines to complain about a 900-page book wasting one line.  However, the complex number is an extreme example of a common occurrence in the chapter.  There is a lot of the chapter that I don’t find particularly essential.

My take on “essential” is Some hints for the R beginner.

Page 16:

A<-1:10
B<-c(2,4,8)

These are two examples of a general feature: while the author’s keyboard seems to work perfectly fine for text, the space-bar is mysteriously broken for R code.

It is clearer to write these as:

> A <- 1:10
> B <- c(2, 4, 8)

The assignment arrow shows up as a separate entity.  Spacesaidunderstanding.

Page 21

The same thing, but this time it’s serious.

x<5

really, really should have spaces around the less-than operator.

There is no trouble with this particular example, but what if the example were with minus five?

x<-5

does not give you a logical vector with TRUE values when x is less than minus five.  It changes x to have the single value 5.

This and a whole bunch of other  R gotchas are in The R Inferno.

Page 107

The values in the body of a matrix can only be numbers.

That is a false statement.  In particular, if x is a numeric matrix, then the result of

x < -5

is a matrix of logical values (and is the same dimension as x).

Pages 323-324

This be praise, not quibble.

The book uses “explanatory variables” and “response” in the statistical regression context.  It doesn’t enter into the dependent-independent muddle.

Other views

Amazon has several reviews of The R Book. There is a range of opinions from very positive to quite negative.  A common complaint is that the material is disorganized.

Questions

The points I have raised are from a quick glance through the book.  Are there other things in the book that should be pointed out to help the unwary?

Epilogue

I don’t think there is such a thing as the best book on R.  There can be the best book on R for you as an individual.  Which one is the best will depend on where you are and where you want to go.  A partial list of your choices is Books related to R.

To leave a comment for the author, please follow the link and comment on their blog: Portfolio Probe » R language.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)