Stage 1 · Lesson 2 of 7
R vectors, types and NA
In R, nearly everything is a : an ordered set of values of one type, such as numeric, character or logical. Maths is vectorised, so prices * 1.18 works on every element without a loop, and functions like mean, sum and sd take a whole vector.
Missing values are NA, and most summaries return NA unless you pass na.rm = TRUE. Categories are stored as , which keep a fixed set of levels and their order, and that order controls how plots and models treat them. Learn creating vectors with c(), indexing with square brackets, logical conditions and the basic types.
Common trapR quietly converting types: mixing a number and a string in c() turns everything into text, and later maths fails or gives nonsense.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with
- BookFreeR for Data Science (2e)
Wickham, Çetinkaya-Rundel, Grolemund · Beginner
Free online: the Whole game and Transform chapters teach the tidyverse verbs in the order you need them