Learn R programming by means of deliberate practice
If you are serious about learning R and being able to use R to solve real-world problems, this book is for you. It is the first volume in a series of compact eBooks, based on the simple premise that the best way to learn programming is by means of deliberate practice. This book offers a lot of practice, through 44 exercises. It also offers you a system to practice deliberately: each exercise is a step up from the previous one, and allows you to discover and practice a new concept, or extension to a concept you practised before.
We’ll take it slowly but thoroughly! The first 50 pages of this book cover the very, very basics of R: Vectors, arithmetic operators and functions, and regular sequences. In many books you will find an explanation of these topics condensed to a few pages, in some online tutorials to a single blog post, and in popular cheat sheets these topics might have been summarized in three or four lines. I don’t think compressing information this way is going to help you to really understand R, and develop the skills to actually use R to solve an actual problem.
A framework to guide your interaction with R
To achieve this latter goal, your most important activity will be to sit down behind a computerscreen and keyboard, and interact with R. The exercises in this book are designed as a framework to guide that interaction, challenge you, and allow you to measure your progress. In fact, just reading this book without access to a computer, unfortunately, will be a waste of your time. I recommend to read the book on your computer screen (e.g. on the right side), and have an R session running on the left side of your screen.
First practice, then apply in new situations
The final 20 pages cover the application of what you practised in the first 50 pages, in new situations. Rather than learning a new concept, or R function, at the end of the book, I will challenge you to develop solutions to real problems, by writing short R scripts using R data structures and functions appropriately.
Throughout the book, the level of difficulty varies somewhat, deliberately. Like a running workout, some exercises act more like a warm-up, while others offer you just a lot of practice (mileage building), and still others aim to push you hard for a while (sprint). You should feel free to “break away from the pack”, and skip an exercise if you are already thoroughly familiar with a particular function, or peek at the solution after you tried many times to solve the problem.
Yes, that wasn’t a typo: All solutions to the exercises are included at the end of each chapter. Right below each exercise you will find a link that will bring you to the corresponding solution in the document right away. And once you get to the end of the solution, you can click a link back to the corresponding exercise. I tried to find a good balance here: When working on an exercise I don’t want you to accidentally see the solution (which is why I didn’t include a solution immediately below an exercise). On the other hand, the solutions include a lot of explanation and are important to read after you’ve done the exercises. So, I created the links between exercises and solutions to allow you to navigate back and forth conveniently.
Now, let’s practise and start the first set. Ready, set, go!