mode() — The most common value

Finds the value that shows up the most.

which.max(table(x))

Key idea

Definition

how often value x appears
the x that makes it largest

In plain words

It is like asking a class “what is everyone’s favorite snack?” — the snack the most kids pick is the mode.

Where you'd use it

Worked example 2

Some kids’ scores: 7, 8, 8, 9, 9, 9, 10, 10, 11. The score 9 shows up the most, so 9 is the mode.

Frequently asked questions

Does R have a mode() for the most common value?
No — base mode() returns the data type. You need a small custom function.