3.1 Introduction

In Chapter 2, we learned that mastering R (or any other programming language) essentially consists in solving two inter-related tasks (see Section 2.1):

  1. Representing various types of information as objects (Section 2.2.1).

  2. Using functions for manipulating those objects (Section 2.4).

We further learned that every data object has a shape and type and encountered some of R’s key data types (or modes, see Section 2.2.2).

A key limitation of Chapter 2 was that we used linear vectors as our only shape of data object. While a vector can have any of the key data types, its shape is characterized by its length (and vectors with only one element are called scalars).

In this chapter, we will encounter additional data structures. For instance, we will see that lists are linear data structures that can store objects of multiple data types and that matrices and data frames are rectangular data structures that can store vectors of a single or multiple data types.

3.1.1 Contents

This chapter extends Chapter 2 by introducing additional R concepts and commands. Its key concept is the notion of a data structure as a specific combination of data types and shapes. Beyond atomic vectors, we will learn to create and access lists, matrices, and data frames.

3.1.2 Data and tools

This chapter only uses base R functions and snippets of example data that we will generate along the way.