ABSTRACT

The third chapter discusses the most important family of data types in base R: vectors. It won’t cover individual vector types in too much detail, but it will show how all the types fit together as a whole.

Vectors come in two flavours: atomic vectors and lists. We start with “Atomic vectors”, which are R’s simplest data structures. For atomic vectors, all elements must have the same type. Then, we take a small detour to discuss “Attributes”, R’s flexible metadata specification. “S3 atomic vectors” discusses the important vector types that are built by combining atomic vectors with special attributes. These include factors, dates, date-times, and durations. Next, we dive into “Lists”. Lists are very similar to atomic vectors. However, an element of a list can be any data type, including another list. This makes them suitable for representing hierarchical data. “Data frames and tibbles” teaches you about data frames and tibbles, which are used to represent rectangular data. They combine the behaviour of lists and matrices to make a structure ideally suited for the needs of statistical data. To finish up this chapter, we briefly talk about one final important data structure that’s closely related to vectors: “NULL”.