scale() — Standardize (z-scores)

Changes each number into how far it is from the middle.

scale(x)

Key idea

Definition

one value
the sample mean
the sample standard deviation
the z-score — steps from the mean

In plain words

For each number it asks: how many steps away from average is this? That step count is the z-score. It lets you compare things measured in different ways using one shared ruler.

Where you'd use it

Frequently asked questions

What does scale() do?
It centres each column (subtracts the mean) and divides by the sample SD, giving z-scores.
Why don’t my values match a hand z-score?
scale uses the sample SD (÷ n − 1); a population z-score uses σ (÷ n).