Introduction to R

2. How does R work?

One of the disadvantages of R is that it is essentially a computer language, and does not use a “graphical user interface” (ie. menus and buttons) like other software do.  Instead, the user types commands directly into a window (the “console”) in the R software.  This is often a reason for people to think that R isn’t for them!  However, with a little bit of time and effort, many people find this an advantage, because once you know the commands, it is much easier and faster to work with than the menu.  In addition, a series of commands can also be pre-written all together in a plain text file called a “script” which you save on your computer just like any other document.  The script is then ran within R and performs the desired analysis.  These scripts can be easily used again and again, or more importantly, very quickly copied and modified to analyze different data or to include different/new analyses.  Using a menu-driven system requires the user to click buttons and make selections – often this is not documented anywhere other than the user’s memory.  In contrast, the script serves as a permanent record of what was performed – this is a key element of “Reproducible Research” (https://en.wikipedia.org/wiki/Reproducibility) which is becoming increasingly important these days, especially in data analysis (https://www.coursera.org/learn/reproducible-research http://www.ncbi.nlm.nih.gov/pubmed/26711717).  R is not alone in the use of scripts rather than menus and buttons – other software also use scripts, recognizing the advantages they afford.

There is a “sort of” graphical user interface called R Studio (https://www.rstudio.com/) which has a free version, but it isn’t anything like you’d find in Stata for example, and we won’t be using it in this course.