Imagine a spreadsheet from a class survey. Row after row of answers: Amara, 162 cm, green, 2 pets, 5 stars. On its own it is a wall of noise. The moment that turns noise into information is a quiet one — deciding what kind of thing each column holds. The height column is a measurement. The colour column is a label. The star column is a ranking. Three columns, three completely different species of data.
This matters because the type of a variable decides every statistic and every chart you are allowed to compute. You can average the heights. You cannot average the colours. You can sort the star ratings but you cannot trust the gaps between them. Get the type wrong and your calculator will still spit out a number — a confident, precise, utterly meaningless number. So before we plot or summarise anything, we learn to read the type.
A variable is any feature that can differ from one observation to the next — a person's height, their eye colour, the number of pets they own. Each recorded value is a datum; all of them together are the data. A variable is the question ("how tall are you?"); the data are the answers the survey collected.
Every variable belongs to one of two great families, and each family splits into two. Four kinds in all — and once you can name them on sight, the rest of statistics falls into place.
Categorical (or qualitative) data records a label or a group — which box you tick. Numerical (or quantitative) data records a quantity you can genuinely do arithmetic with.
The whole point of classifying first: the average of eye-colours is meaningless. You can count how many people have brown eyes, but "the mean eye colour" is nonsense — there is no number there to add. Type comes before computation.
A continuous variable lives on an unbroken line — every point is a possible value. A discrete variable lands only on separate, countable spots. A categorical variable is just a set of named markers with no numeric scale at all. One picture, three different worlds:
A sports club records this about each member. Name each variable's kind before reading on.
Notice how "is it written with digits?" is not the test. Goals and jersey numbers are both written with digits, yet only one is truly numerical. The test is: does arithmetic on it mean anything? Adding two goal-counts is sensible. Adding two jersey numbers is not.
Take five people's heights: 158, 164, 171, 169, 173 cm. The mean is
That 167 cm is real and useful — it names a typical height, sits on the same scale as the data, and would guide the size of a doorway. Now try the same with five eye colours: brown, blue, green, brown, hazel. What is
There is nothing to add. Colours are not points on a scale, so no sum exists and no mean exists. The only honest summary of nominal data is a count or the mode (the most common category) — here "brown", which appears twice. Categorical data has statistics of its own; the mean simply is not one of them.
The underlying feature does not fix the type — how you record it does. Take age. Ask "how old are you?" and record 19 and you have a numerical (continuous) variable: you can average it, and the mean age of a room is a meaningful number.
Ask instead "which age band are you in?" — under 18 / 18–29 / 30–49 / 50+ — and record "18–29", and the very same underlying age has become categorical (ordinal): ordered bands with no single number inside. You can say which band is most common, but you can no longer compute a mean age, because you threw the exact numbers away when you bucketed them.
This is a genuine trade-off pollsters make every day. Bands protect privacy and are quicker to tick — but they coarsen the data and lock you out of the arithmetic. Choosing how to record a variable is choosing what you will later be allowed to compute.
This is the single most common data-type mistake, and calculators are complicit in it. A jersey number, a postal code, a phone number, a bus route number, or a survey code where 1 = agree, 2 = disagree, 3 = no opinion — every one of these is written with digits, yet every one is categorical data in disguise. The digits are just names.
Feed jersey numbers 4, 7, 10 and 23 into a spreadsheet and ask for the average and it will cheerfully return 11. But there is no meaning in "the average jersey number is 11" — number 11 is a different player, not the middle of anything, and if the team renumbers its shirts tomorrow your "average" changes while nothing about the team has. The same trap swallows survey codes: averaging 1 = agree and 2 = disagree to get "1.5" pretends there is a halfway opinion sitting on a scale, when the codes were only ever labels.
The test, every time: would the number still mean something if the codes were swapped for words? "The average of red and blue" is obviously nonsense — and so is "the average of postal code 90210 and 10001", even though the calculator won't complain.
Everyone treats star ratings as numbers — apps proudly average them to "4.6 stars", shops sort by them, algorithms rank by them. But strictly, a star rating is ordinal, not numerical, and the reason is subtle and beautiful: the gaps aren't guaranteed to be equal.
Is the jump in quality from 1 star to 2 stars really the same size as the jump from 4 stars to 5? For most people it isn't — 1-star means "actively awful", 2-star "bad", while 4 and 5 both mean "great, splitting hairs". The scale is ordered (5 beats 4 beats 3) but the spacing between the rungs is unknown and uneven. Averaging assumes every step is worth exactly the same, which ordinal data never promises.
In practice we bend the rule constantly — averaging stars is convenient and roughly useful — but a careful analyst remembers it is a convenient fiction. It is why serious reviewers often report the distribution ("mostly 5s with a spike of angry 1s") rather than a single mean, which can hide a bitterly split crowd behind a comfortable-looking 3.5.
Treating categorical codes as numbers has caused real damage. Encode countries as 1, 2, 3, … and a naive model will conclude country 3 is "bigger" than country 1, or that the "average country" is 2 — pure artefacts of the arbitrary numbering. Encode a colour-blindness result as 0 = pass, 1 = fail and someone will report a "mean of 0.3" as though a third of a person failed.
The fix data scientists reach for is one-hot encoding: instead of one column holding codes 1/2/3, you make a separate yes/no column for each category, so no fake ordering can sneak in. It is a whole technique that exists purely to undo the "numbers that are really labels" trap — proof of how often, and how expensively, people fall into it.