sample() — Random sampling

sample(x, size, replace = FALSE)

Key idea

Definition

how many items in the pool
how many you draw
ways to draw when order is ignored, no repeats

Where you'd use it

Frequently asked questions

Does sample repeat values?
Not by default. Use replace = TRUE to allow repeats.
Why do results change each run?
It’s random — set.seed() makes it repeatable.