# The Art of R Programming – my two cents

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

What makes this book different from other books about R is stated clearly by the author Norman Matloff in the introduction:**One R Tip A Day**, 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.

Most books about R present a gentle introduction to the language and then jump to practical applications. Norman Matloff, across the 350 pages of this book, accompanies the reader in developing the necessary skills useful to write software in a proper way focusing on the characteristics and idiosyncrasies of the R language.“This book is not a compendium of the myriad types of statistical methods that are available in the wonderful R package. It really is about programming and cover programming-related topics missing from most other books on R”.

In each of the first six chapters of the book the author covers a different R data type: vector, matrix, list, data.frame and factor. Starting from basic examples and progressing to more complex ones each data type is properly introduced and used in the proper context. Furthermore, some extended examples are ameliorated or re-implemented along new type are introduced in order to show the expressivity of the language. The explanation of small details such as the use of the

*drop=FALSE*argument in matrix/data.frame subsetting or the

*stringsAsFactor=FALSE*argument when building up a data.frame are the proverbial icing on the cake which can make your day-by-day workflow more productive.

Chapter 7, 8 and 9 are the heart of the Art of R Programming introducing the structures, idioms, peculiarities and idiosyncrasies of R as programming language.

Chapter 7 presents how the typical programming structures are implemented in R and how to use them correctly: control statements, functions, recursion etc. are explained by clear and appropriate examples of increased complexity and usefulness.

Chapter 8 about doing math and simulation in R is a more ‘traditional’ chapter depicting the mathematical/statistical facilities embedded in R. Since the main selling-point of R is its statistical capabilities an introduction to their characteristics and use makes perfectly sense.

Chapter 9 covers S3 and S4 the two most commonly used paradigms of object-oriented programming (OOR) implemented in R. If you are going to start designing and developing R software in a proper and reusable form this chapter will provide all the necessary information and a good collection of examples tailored to R mathematical/statistical peculiarities.

Chapter 10 is about I/O and provides all the necessary directions needed to parse data in R locally and from the internet.

Chapter 11 is about string manipulation and it is less technical than former chapters, presenting a sort of cheat-sheet collection of the most common functions to handle string in R. The author covers the string capabilities embedded in base R but advices to take a look at Hadley Wickham’s stringr package for a more consistent handling of strings in R.

Chapter 12 introduces graphics in R providing a gentle overview of the huge R graphics capabilities but it doesn’t present an in-depth discussion. Fortunately there are a lot of other books (for example Paul Murrel’s R Graphics) dedicated to this subject which is indeed one of the R’s strong points.

Chapter 13 about debugging is short but points out almost everything is important to know about debugging R code; furthermore it provides a wide vision about debugging in general: the author Norman Matloff is also the co-author of The Art of Debugging with GDB and DDD and clearly he knows the matter of which he speaks.

Chapter 14 covers strategies to handle the time/space trade-off in order to enhance the performance of R programs. In particular it explains the proper use of vectorization in order to speed up your code.

Chapter 15 and 16 are a sort of follow-up to chapter 14, meaning that they explain how to enhance the performance of your code by integrating R with other language, such as Python and C/C++ (Chapter 15) and by parallelizing your code. Both chapters provide an introductory glance on these topics but present sufficient coverage in order to be useful.

Conclusions:

Is it worth to buy this book? The short answer is YES. If you are serious in learning R in order to both analyze in the most appropriate and effective way your data (e.g. using the appropriate data type according your specific task) and to develop software, The Art of R programming will be beneficial to you.

Caveats: since the peculiar approach and aim of this book my advice is to buy this book together with a more statistical oriented, for example Rob Kabacoff’s R in Action and one or two about graphics in R (e.g. Hrishi Mittal’s R Graph Cookbook or Hadley Wickham’s ggplot2 book).

Disclaimer: No Starch Press provided me a free copy for review.

To

**leave a comment**for the author, please follow the link and comment on their blog:**One R Tip A Day**.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.