2 Why R?

If you are brand new to R and programming, you may be scared. You aren’t used to having to type commands to tell the computer what to do. You may be more used to using drop-down menus and other graphical user interfaces that allow you to pick what you’d like to do. So why are so many companies, colleges/universities, and individuals of all disciplinary backgrounds shifting towards using R?

There are lots of answers to this question, but some of the most important for us now are:

  1. R is free. RStudio is free.

    One of the biggest perks about working with R and RStudio is that they are both provided free of charge to use. R is an open-source programming language that has grown tremendously in recent years with developers adding more functionality and packages on a daily basis. Where other more proprietary packages are sometimes stuck in the dark ages (the 1990s, for example) of development and can be incredibly expensive to purchase, R continues to be a free alternative that allows users of all levels to contribute.

    RStudio is a graphical user interface that allows one to write R code and view the results of that code in an easy way. It is also free to download and work with.

  2. Analyses done using R are reproducible.

    As many scientific fields push towards more reproducible analyses, the point-and-click proprietary systems actually serve as a hindrance to this process. If you need to re-run your analysis using these systems, you’ll need to carefully copy-and-paste your analysis and plots into your text editors from potentially beginning to end. Anyone that has done this sort of copy-and-pasting knows that it is prone to errors and incredibly tedious.

    If you use the workflows described in this book, your analyses will be reproducible so you don’t need to worry about these copy-and-pasting issues. As you might have guessed by now, it would be much better to be able to update your code/data inputs and re-run all of your analysis than to have to worry about manually moving your results from one program to another. Reproducibility also helps you as a programmer since your greatest collaborator will probably be yourself a few months or years down the road. Instead of having to carefully write down all the steps you took to find the right drop-down menu option, your entire code is stored.

  3. Using R makes collaboration easier.

    This also helps you with collaboration since, as you will see later, you can share an R Markdown file containing all of your analysis, documentation, commentary, and the code to others. This reduces the time to needed to work with others and reduces the likelihood of errors being made in following along with point-and-click analyses. The mantra here will be to Say No to Copy-And-Paste! both for your sanity and for the sake of science.

  4. Finding answers to questions is much simpler.

    If you have ever had an issue with software, you know how difficult it is to find answers to your questions. “How can I describe the process to someone else? Do I need to take screenshots? Do I really need to call IT and wait for hours for someone to respond?” R is a programming language and so it is much easier (after a bit of practice) to use Google or Stack Overflow to find answers to your questions. You’ll be amazed at how many other users have encountered the same sorts of errors you will see when you begin.

    I frequently (almost on a daily basis) Google things like “How do I make a side-by-side boxplot in R coloring by a third variable?”. You’ll become better at working with R by reaching out to others for help and by answering questions that others have. In addition, Chapter 6 describes many common errors and how you can fix them.

  5. Struggling through programming helps you learn.

    We all know that learning isn’t easy. Do you have trouble remembering how to follow a list of more than 10 steps or so? Do you find yourself going back over and over again because you can’t remember what step comes next in the process? This is extremely common especially if you haven’t done the procedure in awhile. Learning via following a procedure is easy in the short-term, but can be extremely frustrating to remember in the long-term. Programming (if done well) promotes long-term thinking to short-term fixes.

    One unfortunate thing that we frequently take for granted is that our brain tricks us into picking the easy route. If you truly want to learn how to do something (like programming with R), you’ll need to feel frustrated at times. Any time you learn something you’ve been frustrated. (We tend to forget all the frustration and only think about where we currently are.) R still frustrates me from time to time, but I grow through practice and I look forward to the challenges. Hadley Wickham encapsulated this phenomenon nicely in the Prologue of the book “Hands-On Programming with R” (Grolemund 2014):

    As you learn to program, you are going to get frustrated. You are learning a new language, and it will take time to become fluent. But frustration is not just natural, it’s actually a positive sign that you should watch for. Frustration is your brain’s way of being lazy; it’s trying to get you to quit and go do something easy or fun. If you want to get physically fitter, you need to push your body even though it complains. If you want to get better at programming, you’ll need to push your brain. Recognize when you get frustrated and see it as a good thing: you’re now stretching yourself. Push yourself a little further every day, and you’ll soon be a confident programmer.


Grolemund, Garrett. 2014. Hands-on Programming with R. O’Reilly.