Chapter 2 Basic R

R project

This chapter provides a very brief introduction to R (R Core Team, 2021b), which is a free software environment for statistical computing and graphics.

More specifically, this chapter covers essential concepts and commands of base R, which essentially is R without any additional packages.

Important concepts and contents include:

  • R objects as data vs. functions;
  • creating and changing R objects (by assignment);
  • different types of data (e.g., Boolean values of type logical, numbers of type integer or double, and text of type character);
  • exploring functions and their arguments;
  • defining different data structures (e.g., scalars, vectors, and tables);
  • accessing and changing elements by indexing or subsetting.


Recommended readings for this chapter include:


Before reading, please take some time to reflect upon the following questions:

i2ds: Preflexions

  • What is being manipulated by computer code?

  • What is the difference between a variable and a function?

  • Which types of data can we distinguish?

  • In which form can variables of different types be stored?

  • In which order is computer code evaluated?

  • Which windows in the RStudio IDE allow interacting with R?

Note: This chapter is still fragmentary. See Chapter 1: Basic R concepts and commands of the ds4psy book (Neth, 2021a) for a more complete account.