Hands-On Programming with R: Write Your Own Functions and Simulations
Use the Amazon App to scan ISBNs and compare prices.
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Frequently bought together
More items to explore
About the Author
Garrett Grolemund is a statistician, teacher and R developer who currently works for RStudio. He sees data analysis as a largely untapped fountain of value for both industry and science. Garrett received his Ph.D at Rice University in Hadley Wickham's lab, where his research traced the origins of data analysis as a cognitive process and identified how attentional and epistemological concerns guide every data analysis.
Garrett is passionate about helping people avoid the frustration and unnecessary learning he went through while mastering data analysis. Even before he finished his dissertation, he started teaching corporate training in R and data analysis for Revolutions Analytics. He's taught at Google, eBay, Axciom and many other companies, and is currently developing a training curriculum for RStudio that will make useful know-how even more accessible.
Outside of teaching, Garrett spends time doing clinical trials research, legal research, and financial analysis. He also develops R software, he's co-authored the lubridate R package--which provides methods to parse, manipulate, and do arithmetic with date-times--and wrote the ggsubplot package, which extends the ggplot2 package.
There was a problem filtering reviews right now. Please try again later.
Compared to other programming languages that I know, I have found it harder to get to that place of knowing a useful subset of R. This is partly because I've never made it a high priority, but also because there seemed to be something unintuitive about the language (especially compared to Python, the language that I use most). I would occasionally pick up a book on R but rapidly lose interest in a day or two, and then rapidly forgetting much of what I had learned.
But then recently I started reading the book "Doing Bayesian Data Analysis" by John Kruschke, which makes heavy use of R. This motivated me to try once again to learn some R. In one chapter, Kruschke introduces Markov Chain Monte Carlo. He discusses the Metropolis algorithm through a toy example involving matching the distribution of a finite discrete distribution. When I read that chapter I quickly wrote a Python script which reproduced the simulation. But it occurred to me that to fully enter into the spirit of Kruschke's book, I should write the simulation in R. I put Kruschke's book to the side, ordered this book from Amazon, and then plowed through it in a week. Today (just 10 days after getting the book) I was able to write a working MCMC model in R.
Pros and cons of the book itself:
Pros: It has a nice discussion of vectors, matrices, lists, and data frames. In some of my previous brief forays into R, I never got to the point of having a really clear mental model as to just how those data structures related to each other. I found his discussions of attributes particularly helpful. His choice of a deck of cards as a data frame struck me as contrived at first but it was effective in giving a basic orientation in how data frames work. The third part, where the author got into programming proper, was the most interesting part, and I found the slot machine example interesting.
Cons: It is pricey for its size (200 pages + appendices), especially given the lack of proper proof-reading. This was close to a deal breaker for me, but I had resolved to learn enough R to write a MCMC simulation and wanted to do so before I returned to the other book. The chapter on environments seemed a bit of a stretch. Using closures to maintain the state of a deck strikes me as baroque, though maybe that is just the Python programmer in me. Furthermore, I suspect that people who are coming to programming for the first time would find that chapter mystifying.
On the whole I was happy with the book. I find myself vacillating between giving it 4 stars or 5 stars. I'm in a good mood today, so I'll give it 5.
R as a programing language has also evolved so much over the past 5 years that I find that the newer books are a better start for beginners, not that the classics should be skipped. This book has a cleaner narrower focus and is a great fit for someone new to R. It uses less libraries and the libraries it uses are clean and make working with R easier. Also I couldn't imagine working with R without using RStudio and this book also shows short cuts on the language's best IDE that is free for personal use.
My suggestion is that someone with little to no experience programing should maybe get two books to learn R. 1) R for Everyone by Jared P. Lander (Though the font for the code in Kindle is frustrating because it doesn't show symbols correctly unless you copy and paste the code!) 2) Hands-On Programming with R by Garrett Gromlemund. Than after under standing these books and maybe doing a few free online courses get 1) The Art of R Programming by Norman Matloff and 2) R in Action by Robert Kabacoff (Only available for sale at the publishers website for the EBook)
What I want is a second book on using Hadley Wickham's libraries as a second book. Using Reshape2, ddplyr, tidyr, stringr, tidyr, ggplot2, ggvis and shiny.
Top international reviews
The author has succeeded in making this an accessible book on learning R, by solving interesting case studies (gambling!) instead of being too abstract.
I don't have any developer experience or training, so was very happy to see good explanations on programming aspects. Its certainly not common sense, but the discussions on R environments was completely new to me, yet seems fundamentally important, and explained why my attempts at writing functions never worked (because variables always seemed to remain unchanged).
Also - kudos to the author, I had a question which I emailed to him, and he responded really quickly. It relates to a sister product so I'll copy an excerpt below:
"You are right: R for Data Science *is* Data Science with R. The name changed after I wrote Hands-On Programming with R. I'm still writing R for Data Science and plan to complete it in July..."
"I recommend that you read Hands-On Programming with R before you read R for Data Science. I wrote it as a prerequisite for the second book (originally they were attached with Hands-On Programming for R as the first part)."
So far, I'm on p. 42 and have just started Part 2 of the book. Garrett Grolemund writes like a teacher talks. The points are well made, explained and situated in a scale appropriate context for a novice programmer.
And there's the rub: Dr Grolemund approaches R in a way that is quite novel for me. He approaches it, and invites the reader to take the same perspective, as a programming language. Readers become apprentice programmers doing data science. His treatment of data objects, how they are combined in functions, replicated and plotted are very well discussed through the models of casino games.
Through four game programmes, Dr Grolemund outlines a host of ways to understand and interact with the large and, for the novice acolyte, a complex, language that is R. Through the use of well documented reader-oriented exercises in programming functions and scripts to perform the mechanics of data analysis, Dr Grolemund gives as close-to-hands-on mode of instruction that I think one can offer. Congratulations to the author for good writing, and clear, tractable examples.
But what is apparent underneath Dr Grolemund's writing is a way of approaching data sets. By crafting routines to handle data, to manipulate it, and to run it multiple times to obtain frequencies and trend patterns, the approach is to programme R and feed it data sets as arguments. This gives the novice the perspective of R as a language with which to express and test ideas using data.
Admittedly, I haven't gotten that far into the book yet. These are early impressions, but let's say ... say far, very good!
Außergewöhnlich gut ist die Didaktik aufgrund
* des sehr verständlichen Sprachstils
* der mit Verstand erstellten und platzierten Schema-Bilder
* des guten Aufbaus unter Verwendung raffiniert gewählter und ausführlich erläuterter Beispiel-Projekte.
Anhand dieser kleinen Beispiel-Projekte wird der Leser in die Konzepte und Besonderheiten der Sprache R eingeführt.
Die für R wichtigen Themen der funktionalen Programmierung und Vektorisierung kommen hier unkompliziert und anschaulich zur Anwendung.
Mit diesem Buch erhält man keine unverdaut bleibenden "R Rezepte zum Abtippen", sondern DIE Anleitung zum Verständnis einer profunden Datenanalyse mit dem Programm R. Wer sich selbst begeistern möchte, sollte hier einfach zugreifen.
I endorse very much the pedagogical concept of this book. It teaches you all the knowledge to master the R programming language by way of three practical challenges: Simulating weighted dice, playing cards and a slot machine. These projects are chosen in a way to learn not only to program but also to understand important concepts of data science (e.g. sampling without and with replication). You will learn to write your first function already in chapter one!