Categorical variable
What is a categorical variable?
A variable whose values are text.
A categorical variable sorts observations into groups. Its values are names instead of numbers, so the arithmetic we are allowed to do on them is limited but very useful. There is no such thing as an average color, but we can count how many people choose each color.
Side note: we often aggregate numerical variables by categorical variables and compare those aggregate measures, for example the average number of siblings of pet owners and of everyone else. Some of the methods we use to aggregate data are count, mean, median, max, min, range, standard deviation, and so on. We cover these concepts further in future lessons.
Sometimes numbers stand for categories and should be interpreted as text: phone numbers, zip codes, classroom numbers, and so on. It is our job to know which variables in our dataset should be treated as categorical and which as numerical.
From our own dataset
Favorite color, pet species.
Where we teach it
Lesson 1.2 of Project 1: Sibling Interviews. Watch lesson 1.2 and read the notes, free with a free account.
Related terms
- Numerical variable: A variable whose values are numbers.
- Binary variable: A variable with exactly two possible values.
- Variable: A characteristic or question we record for each observation.
- Value: A single data point.