Lecture 2: Software, software, software!

Daniel Hammarström

R: A system for statistical computation and graphics

  • A computer language (with runtime environment)
  • A graphics engine
  • Access to system functions and ability to run user-created R programs.

  • We can talk to R through the console by running scripts or individual commands.
  • The base installation of R comes with a Graphical User Interface (GUI)
  • We will use R in an Integrated development environment

Basic R: A calculator

Basic R: Everything is an object

  • The assignment operator (<-) assigns values to objects
  • Assignment can be made with <-, -> and =.
  • All assignments saves objects in your environment

Basic R: Data types

  • c is a function that combines values into vectors
  • Vectors can be of different types, numeric, character, logical…

Basic R: Vectorized operations

  • Vectorized operations makes computations efficient
  • Single values are re-used

Basic R: Functions

  • Functions are central to R programming
  • Functions are also objects

RStudio, an integrated development environment

RStudio, an integrated development environment

  • We will communicate with R using RStudio
  • RStudio puts all part of your workflow in one environment (integrated development environment)
  • RStudio highlights code and finds errors and makes it easy to keep track of files

From (Peng 2011).

(Wickham and Grolemund 2017)

Reproducible reporting software

Figure 1

Thank you!

Peng, R. D. 2011. “Reproducible Research in Computational Science.” Science 334 (6060): 1226–27. https://doi.org/10.1126/science.1213847.
Wickham, Hadley, and Garrett Grolemund. 2017. R for Data Science: Import, Tidy, Transform, Visualize, and Model Data. 1st ed. Paperback; O’Reilly Media. http://r4ds.had.co.nz/.