Jump to ratings and reviews
Rate this book

Hands-On Programming with R: Write Your Own Functions and Simulations

Rate this book
Learn how to program by diving into the R language, and then use your newfound skills to solve practical data science problems. With this book, you'll learn how to load data, assemble and disassemble data objects, navigate R's environment system, write your own functions, and use all of R's programming tools.RStudio Master Instructor Garrett Grolemund not only teaches you how to program, but also shows you how to get more from R than just visualizing and modeling data. You'll gain valuable programming skills and support your work as a data scientist at the same time.Work hands-on with three practical data analysis projects based on casino gamesStore, retrieve, and change data values in your computer's memoryWrite programs and simulations that outperform those written by typical R usersUse R programming tools such as if else statements, for loops, and S3 classesLearn how to write lightning-fast vectorized R codeTake advantage of R's package system and debugging toolsPractice and apply R programming concepts as you learn them

250 pages, Kindle Edition

First published October 22, 2013

141 people are currently reading
367 people want to read

About the author

Garrett Grolemund

7 books18 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
125 (52%)
4 stars
83 (34%)
3 stars
21 (8%)
2 stars
7 (2%)
1 star
2 (<1%)
Displaying 1 - 28 of 28 reviews
Profile Image for Peter Baumgartner.
42 reviews6 followers
May 5, 2017
A very gentle introduction to programming with R. It starts very easy but covers step by step a wide range of topics. If you want to learn R from scratch and you are a newcomer to programming, then this book is definite for you!

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 like sampling without and with replication. You will learn to write your first function already in chapter one!

Profile Image for Miki Bálint.
1 review
January 17, 2019
The author effortlessly touches on central issues in programming in R, using three gambling projects as excuse. The book was most helpful and interesting, I can only recommend it. In addition, it was also very enjoyable, which is a quality on its own.
Profile Image for Vysloczil.
118 reviews72 followers
December 31, 2020
It is a very good basic introduction, even for people that never dealt with R. In the end it gets quite advanced for an intro book. A similar path could be taken with R for Data Science by Grolemund and Wickham by learning R while looking at basic data science applications. If you are an avid R user, get it. Or consult the free e-book version often: https://rstudio-education.github.io/h.... For advanced issues you have to consult "Advanced R" (free as ebook), "The Art of R Programming" (a bit outdated), or maybe "Efficient R Programming" (free as ebook).
Profile Image for Jenny.
265 reviews23 followers
May 9, 2019
I found this book to be a very helpful beginner's guide to R with some engaging programming examples. Highly recommend that you work through this one before you read the companion book, R for Data Science. I'm incredibly grateful that Grolemund and Wickham have made these two volumes free and open source.
Profile Image for Huong Pham.
147 reviews40 followers
October 29, 2023
When I first started using R for data analysis, I didn't have to write code from scratch. I was provided with pre-written code, and all I had to do was replace the data to get results and interpret those results. So when I encountered errors, I had to google and attempt to fix them following instructions, all while lacking the fundamental knowledge that this book provides. This made me quite stressed and consumed a lot of time.

Highly recommend this book for R beginners.
Profile Image for Yuekun Liu.
157 reviews4 followers
February 24, 2020
Considering might teach R in the future, I will be reading some tool books on it.
This is a very good introduction book. Basically you could help yourself feel comfortable using R within literally a few hours.
Profile Image for Reinhardt.
246 reviews2 followers
May 22, 2020
An excellent intro to R programming. The writing is exceptionally clear and well organized. Rather than just randomly talk about R, this book follows a deliberate pedagogical strategy. The tone is friendly, but the text is not bloated. On the contrary, there are no wasted words, or even rocky sentences. The author is a gifted communicator.

This book is so exceptionally clear and enjoyable it belongs in the computer education hall of fame together with Andrew Tannenbaum's Operating System book (the one than inspired Linux).

It covers all the basics or R and even includes some background on R's implementation of objects. It does all this with an R project that is built throughout the book. The project is a [text based] slot machine with a specific payout. Brilliant way to teach computer programming.

It even includes a chapter on making your R code faster, which for most beginners is not a big deal, but in the case of R, it highlights one of its key strengths - almost all functions in R are vectorized making loops far less common.

If you are learning R, you would be foolish to ignore this book. (An online version is available)
13 reviews7 followers
August 10, 2020
I started from scratch using this book. Problem based learning is a really good way to keep you motivated and interested, and it was used in this book. Also dividing in three different projects was also a great choice for a book like that, since i think that if there were only one project it would become too tiring and boring.
Right now I'm looking forward to read Data Science with R.I hope it is as good as this one!
3 reviews
January 31, 2025
An introductory book exploring essential programming code in R, using RStudio, around three concrete exercises.
I enjoyed the book, as it covers the basics, around three exercises of gambling (dice, cards, slot machine) that are stimulating.
It is considered to be the Volume I, that can be followed by 'R for Data Science', also available online for free.
2 reviews
December 23, 2022
Containing basic principles about how R works, such as how R deal with objects and their attributes or classes and S3 system, how R and R functions work in hierarchical environments, and how to take advantages of vectorized code in R to run faster.
Profile Image for Kauã Fillipe.
133 reviews
December 22, 2023
Uma aula bem completa de R, serve tanto pra quem deseja entrar em contato com a linguagem pela primeira vez como pra quem já tem experiência no assunto. Mistura prática com teoria de uma forma muito didática.
Profile Image for Veli.
3 reviews
September 20, 2018
Clear and easy to follow on explanations. Gives a good basis.
92 reviews3 followers
August 14, 2019
Good one to understand the basics of R Programming. It gives the basics and fundamentals required to understand the syntax of R Programming.
Profile Image for John Zugelder.
Author 1 book3 followers
September 16, 2019
A nice primer on programming in general, that will set you up well to start working with data in R.
10 reviews1 follower
September 24, 2019
This book is really a simple guide to learn R, I recommend this book to all data scientists willing to scratch the surface of R for Data science.
Profile Image for Matheus Guerrero.
2 reviews
August 23, 2020
A short book, direct and efficient in its message. It covers the basics of R programming in an intuitive and didactic way. A must-read for beginners.
34 reviews2 followers
November 13, 2021
Pretty nice book. It gives quite good insight into R programming even for experienced people. I liked it a lot.
Profile Image for Taliarochminska.
285 reviews12 followers
January 19, 2023
hideous topic but 3 for the effort to make the best out of it

Thanks Garrett
25 reviews
February 5, 2015
Another great resource for learning R. While it is frustrating that all these books cover the same basic information they all cover it slightly differently. This book coming from the RStudio's chief trainer is a well designed book which covers many aspects not covered as well as other books.

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.
Profile Image for Arthur.
96 reviews5 followers
September 2, 2014
In short, it is fun, fun to read! Every chapter or exercise is full of tasteful, useful insight as the author takes you thru accomplishing several very engaging projects. You will learn a wealth of not so obvious techniques which will help you build better performing, more accurate apps, faster working code with fewer bugs and jump with you into some under-explored areas or R.
I like the part on vectorization the most, and even tried to change my code to doing it,but it is still a work in progress as I can't QA my change to my liking. The other parts of the book that I liked and trust will be of help to most readers are working with data-frames, matrices, vectors,lists, also environments (did not see this covered anywhere else).
S3/4 and ref classes were, and largely remain obscure after reading this book. The plotting was hardly covered. Pity, it is such an in-demand topic.Integration with other languages is not there, too.
So, there is room for more improvement, nevertheless, the book I foresee will spark more interest in exploring R further.
The bottom line is,the book can serve as an additional or supplementary material and inspire more reading.
I am giving this book four stars out of five.
Disclaimer: the book was provided to me for free under the O'Reilly reader review program rules.
Profile Image for Maruti.
31 reviews12 followers
July 4, 2020
This is sort of in a pair with Data Science with R, so some basic concepts have been omitted here because they are introduced in the latter.

Still, I checked out multiple introductory R books, and this one seemed the best, and because of it's projects, makes learning easy.
Profile Image for Sexy Scientist.
33 reviews
August 12, 2024
If you don't know the abc of any programming language, this is the book you should pick to learn basics of R. It is a very fun book which does not presume that the reader knows at least "this". The book is in first person. It feels like a cool uncle is teaching us in person, dad jokes included. I highly recommend this to book if you have no idea about coding and want to have some fun leaning the basics.
Profile Image for Ryan McShane.
60 reviews
June 15, 2021
This was a very fast read for me, as Grolemund & Wickham make it so. The authors give a tour of some serious aspects of programming with R in a fun way -- programming three games of chance. I used this book to support a similar activity in one of my courses this Spring semester (2021), and most students came out with a better understanding of the nuances of R, as well as better coding practices.
Profile Image for Sergii Khomenko.
19 reviews11 followers
August 9, 2015
A nice entry level book: would recommend to people who interested to start with R, for myself found just a couple interesting moments.
Displaying 1 - 28 of 28 reviews

Can't find what you're looking for?

Get help and learn more about the design.