Chapter 1 Introduction

Years ago, Patrick Burns wrote The R Inferno, a guide to R for those who think they are in hell. Upon first encountering the language after two decades of using Python, I thought Burns was an optimist—after all, hell has rules.

I have since realized that R does too, and that they are no more confusing or contradictory than those of other programming languages. They only appear so because R draws on a tradition unfamiliar to those of us raised with derivatives of C. Counting from one, copying data rather than modifying it, lazy evaluation: to quote the other bard, these are not mad, just differently sane.

Welcome, then, to a universe where the strange will become familiar, and everything familiar, strange. Welcome, thrice welcome, to R.

1.1 Who are these lessons for?

completed a Master’s in library science five years ago and has done data analysis for various school boards since then. He learned Python doing data science courses online, but has no formal training in programming. He just joined team that uses R and R Markdown to generate reports, and these lessons will show him how to translate his understanding of Python to R.
has been building dashboards for a logistics company using Django and D3 while also doing systems administration and managing deployments. The company has just hired some data scientists who would like to rebuild some of her dashboards in Shiny. Padma isn’t a statistician, but would like to learn enough about R to help the analysts and get their code into production.

1.2 How do I get started?

You will learn as much or more from the exercise in this book as from the lessons themselves. To start, you can create an account on, clone the tidynomicon project, and work in that. If you prefer to work on your own computer, you must install R and then install RStudio. We recommend that you do not use conda, brew, or other platform-specific package managers to do this, as they sometimes only install part of what you need. You will need additional software packages as we go along; each shall be named and summoned in due course.