R for modellers - Vignette 01

Introduction to and installation of R

Julien Arino

Department of Mathematics

University of Manitoba*




* The University of Manitoba campuses are located on original lands of Anishinaabeg, Cree, Oji-Cree, Dakota and Dene peoples, and on the homeland of the Métis Nation.

Foreword: the R language

R was originally for stats but is now much more

  • Open source version of S
  • Appeared in 1993
  • Currently version 4.3.3
tail(rversions::r_versions(), n = 8)
    version                date              nickname
127   4.2.0 2022-04-22 07:05:41 Vigorous Calisthenics
128   4.2.1 2022-06-23 07:05:33     Funny-Looking Kid
129   4.2.2 2022-10-31 08:05:54 Innocent and Trusting
130   4.2.3 2023-03-15 08:06:01      Shortstop Beagle
131   4.3.0 2023-04-21 07:06:14      Already Tomorrow
132   4.3.1 2023-06-16 07:06:07         Beagle Scouts
133   4.3.2 2023-10-31 08:07:42             Eye Holes
134   4.3.3 2024-02-29 08:07:53       Angel Food Cake

R uses a lot of code from other languages

  • One major advantage in my view: uses a lot of C and Fortran code. E.g., deSolve:

The functions provide an interface to the FORTRAN functions ‘lsoda’, ‘lsodar’, ‘lsode’, ‘lsodes’ of the ‘ODEPACK’ collection, to the FORTRAN functions ‘dvode’, ‘zvode’ and ‘daspk’ and a C-implementation of solvers of the ‘Runge-Kutta’ family with fixed or variable time steps

Lots of people use R

  • Very active community on the web, easy to find solutions (same true of Python, I just prefer R)



  • This also means that ChatGPT or Google Gemini are quite good at answering questions about R

R is a scripted language

  • Interactive


  • Allows you to work in real time
    • Be careful: what is in memory might involve steps not written down in a script
    • If you want to reproduce your steps, it is good to write all the steps down in a script and to test from time to time using the command line; see Vignette 24

Similar to matlab and Python..


.. with some differences, of course! Otherwise, where would the fun be? ;)

Installing R

The main location - CRAN



  • To install, select your OS from the main page

A note for Linux users


  • Often, the version on your distribution is not the most up to date


  • Instructions are on CRAN about setting things up so you have the latest version. For instance,

Development environments

  • Terminal version, not very friendly
  • Nicer terminal: radian
  • Execute R scripts by using Rscript name_of_script.R. Useful to run code in cron, for instance
  • Integrate into jupyter notebooks and VS code
  • Use IDEs:
    • RStudio has become the reference; see Vignette 02
    • RKWard is useful if you are for instance using an ARM processor (Raspberry Pi, some Chromebooks..)