Chapter 2 First steps

In the following you will find some information about R and RStudio together with instructions for installing them.

2.1 R

  • R ( is a free software environment (actually it is a programming language) for statistical computing, data analysis and visualisation (graphics).

  • R is an open source project, which means that it depends on a worldwide community of active developers to grow and evolve.

  • At the beginning of ’90s professors Ross Ihaka and Robert Gentleman started working on a programming language (running on Mac) to use in undergraduate statistics courses. Ihaka and Gentleman kept the project secret from the wider community until August 1993 when a usable version of R appeared on StatLib. In 1995, the duo made R’s source code available under a free software license. In 2000, R version 1.0.0 was released, the first version ready for public usage. Have a look here (Thieme, N. (2018), R generation. Significance, 15: 14-19) for the full history of R.

  • R compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.

  • The Comprehensive R Archive Network (CRAN) is a network of web servers around the world that store identical, up-to-date, versions of code and documentation. Currently (Oct. 2021), the CRAN package repository features about 18319 packages which extend the base release of R (to load, manipulate data, visualise, model data, to report results, for spatial, financial, time series data and much much much more). See here for the full list of packages:

  • The R community is very active and supportive (see e.g. If you have a problem with R, or you want to code something specific, try with a Google search. In 90% of the cases someone has already implemented what you need (and the code is available in the web!).

2.2 Why R?

  • R vs Excel: there is no discussion here. If you want to use Excel for your high-level data analysis, have a look here and change immediately your mind, please!
  • R vs Python: Python is another great language for data science. I think that Python is more like a general-purpose programming language used for different types of applications (e.g., data science, web development, database), while R is a programming language specifically developed for data analysis and visualization. There is an ongoing debate between R and Python (read here for example). I think there is no winner to find; they are both great language with different purposes.

2.3 RStudio

RStudio ( is a free and open-source integrated development environment (IDE) where to run R code.

To run RStudio you need to install R first! R will do all the calculations for you (it’s your engine), while RStudio is just a convenient environment where to work (for a nice confortable programming journey), it’s the interface between you and R. So, you can just launch RStudio to use R.

The RStudio window is divided in 4 panels, as shown here below.

In the top-left panel (source editor panel or code editor panel) you have your scripts, i.e. text file where to write R code. In the left-bottom panel (R console panel) you see the numerical results of your analysis; it is also the place where you can execute your code instantly (without running it from a script). The right-bottom panel (File/Plots/Packages/Helps panel) displays plots and help pages. Finally, the top-right panel (Environment panel) is used mainly to know the objects in the workspace, to read the history of commands and to import file.

2.4 How to install R

Go to and select your operating system (OS) between Linux, Mac OS and Windows.

If you are a Mac user, download the R-4.1.1.pkg file and proceed as usual for installing new software:

At the end you will find an icon (named R) in your dock and in your Applications list.

If you are a Windows user, download the R-4.1.1-win.exe file and proceed as usual for installing new software:

In Windows, once you install the program, it will create a folder in your ‘Program Files’ directory containing the different bits and pieces that make up R. You should never go into these files. At the end of the installation you will find an icon (named R) on your desktop and also in the Start Menu.

2.5 How to install RStudio

Install the free version of RStudio for your own operating system from this link: Choose the proper version according to your OS. Proceed as usual and find the icon on your desktop/dock.