Track 1 · Statistical Thinking · Lesson 3 of 10
Variables and observations
Identify the unit of observation in a dataset and classify each variable as categorical or quantitative, discrete or continuous.
An analyst counts the rows of a sales file and reports “4,160 customers” — but each row was one store in one week, not a customer. Knowing what a row represents and what kind of values each column holds is the first step of every sound analysis, and the step most often skipped.
Data are usually arranged in a table. Each row is one observation — one unit of observation, the thing being measured: an employee, a patient admission, a store-week, a production day. Each column is a variable: a characteristic that can take different values from one unit to the next.
The unit of observation decides what a count of rows means and what a summary describes. “Mean weekly sales” computed from store-week rows describes store-weeks, not stores and not customers.
Dataset
Employee commute times
240 rows · one row = one employee (their typical one-way commute) · synthetic data
| Employee | Travel mode | Shift | Distance (km) | Commute time (minutes) |
|---|---|---|---|---|
| E001 | car | day | 9.6 | 24 |
| E002 | car | day | 13.2 | 38 |
| E003 | bus | day | 17.4 | 71 |
| E004 | walk | morning | 2.5 | 24 |
| E005 | walk | day | 0.9 | 10 |
| E006 | car | day | 7.6 | 22 |
One row = one employee. mode and shift are categorical; distance_km and commute_min are quantitative.
| Dataset | One row is… | Rows |
|---|---|---|
| commute | one employee | 240 |
| retail_weekly | one store in one week | 4,160 |
| flight_delays | one scheduled flight departure | 2,500 |
| engagement_population | one department | 6 |
| campaign_funnel | one marketing channel in one week | 130 |
Variables come in two broad types.
- Categorical (qualitative) variables place each unit in a group: travel mode, department, blood type, whether a loan defaulted. Some categories have a natural order (job level L1–L5, a 1–5 satisfaction rating); these are ordinal — more on that in Measurement scales.
- Quantitative (numerical) variables are measured amounts where arithmetic makes sense: salary, distance, number of defects.
Quantitative variables split again:
- Discrete: countable values with gaps between them — number of children, calls per hour, goals scored.
- Continuous: any value in a range, limited only by the precision of measurement — weight, time, temperature, distance.
Worked example
Classifying the student_scores variables
The student_scores dataset has one row per student, with columns student_id, school_type, prior_score, study_hours_week, attendance_pct, tutoring and exam_score. Classify each.
Unit of observation: one student (400 rows, 400 students).
student_id— an identifier, categorical (and not analysed).school_type(Public, Private, International) — categorical.tutoring(true/false) — categorical with two values, often called binary.prior_scoreandexam_score— quantitative, recorded as whole points 0–100, so discrete in practice (though they measure an underlying continuous ability).study_hours_weekandattendance_pct— quantitative and continuous: they can take any value in a range.
Three categorical variables (ID, school type, tutoring) and four quantitative ones (two discrete-in-practice scores, two continuous measurements).
Quick check
A delivery company records, for each parcel, the number of delivery attempts needed. What type of variable is that?
Exercises
The lesson is complete when every exercise is answered correctly. Hints are free; viewing a worked solution before solving means the exercise won't count towards mastery.
0 of 7 exercises correct (not saved — sign in to keep your progress)
Exercise 1 · Practice, difficulty 1 of 3
Classify the variables
Classify each variable recorded by a hospital outpatient clinic.
Exercise 2 · Practice, difficulty 1 of 3
What is one row?
Match each dataset to its unit of observation (what one row represents).
Exercise 3 · Practice, difficulty 1 of 3
Digits that are not numbers
Which of these variables are categorical even though they are written with digits? Select all that apply.
Exercise 4 · Application, difficulty 1 of 3
Who was tutored?
In the student_scores dataset (one row per student), how many students attended the tutoring programme (tutoring is true), and what percentage of all students is that (1 decimal place)?
Data: student_scores · Open in the lab to explore and calculate.
Exercise 5 · Practice, difficulty 2 of 3
How many rows?
A pharmacy chain stores its sales data with one row per store per week. It has 64 stores and keeps 13 weeks of history, recording 7 variables (store, week, sales, footfall, …) in each row. How many rows does the table have?
Exercise 6 · Interpretation, difficulty 2 of 3
The average department
In an HR file, departments are coded 1 = Operations, 2 = Sales, 3 = Technology, 4 = Finance. An analyst reports that “the mean department code is 2.3, so the typical employee works close to Sales.” What is wrong?
Exercise 7 · Interpretation, difficulty 3 of 3
Customers or transactions?
An online retailer exports a table with one row per transaction: customer ID, date, basket value. An analyst counts 12,400 rows, reports “12,400 customers” and computes the mean basket value as “the average customer's spend”. In two or three sentences, explain the problem and how to fix it.
What you can now do
- State the unit of observation of a dataset and what a row count means
- Classify variables as categorical or quantitative, and quantitative ones as discrete or continuous
- Recognise numeric codes and identifiers as categorical
- Restructure data so that summaries describe the intended unit