Chapter 2 R Objects (I): Atomic Vectors

Object assignment (Chapter 1.3) gave you the power to name and reuse values. The next step is to understand what those named values actually are. In R, almost every data structure you meet ultimately reduces to an atomic vector: a one-dimensional sequence of values that all share the same underlying type.

Chapter 2 is about mastering those building blocks. You will learn how to create vectors from scratch, reshape them into useful patterns, and apply R’s vectorized operations confidently. Along the way you will discover how R stores different kinds of information—numbers, text, logical flags, dates, and more—and how to keep those types straight as you analyze data.

At a glance – Chapter 2 roadmap
Section 2.1. Numeric vectors: Create numeric sequences, recycle values, and perform arithmetic in a vectorized way.
Section 2.2, Section 2.9, Section 2.10, Section 2.11. Character vectors: Build strings, concatenate text, sort or reorder labels, and decide when to convert them to factors.
Section 2.3 & Section 2.13. Logical vectors: Record yes/no information, combine conditions, and use logical indexing.
Section 2.4. Type coercion: Predict how R converts between vector types when they meet in the same object.
Section 2.5 to Section 2.14. Working with vectors: Subset, modify, rank, summarize, and compare vectors efficiently.
Section 2.15 to Section 2.17. Special values and extensions: Handle NA, NaN, and Inf, work with dates/times, and meet complex and raw vectors.


Buy Me A Coffee