Chapter 5 Data Structure Basics

Smart data structures and dumb code works a lot better than the other way around Eric S. Raymond

The term data structure refers to the type of values stored within an object and the manner in which those values are arranged. The basic data structures in R can be organized by an object’s dimensionality (1D, 2D, …, nD) and whether or not it is ‘atomic’. Atomic structures can only contain elements that are all of the same type (homogenous) while non-atomic structures can contain elements of one or more types (heterogeneous). This categorization results in five primary data structures as shown in Table 5.1. These primary data structures are most often used in data analysis; and almost all other objects in R may be built from these foundational types.

Table 5.1: Types of data structures in R (adapted from Advanced R, H. Wickham)
Dimensions Homogenous Heterogenous
1D Atomic Vector List
2D Matrix Data Frame
nD Array