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.

20 minFoundation7 graded exercisesFree

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

EmployeeTravel modeShiftDistance (km)Commute time (minutes)
E001carday9.624
E002carday13.238
E003busday17.471
E004walkmorning2.524
E005walkday0.910
E006carday7.622

One row = one employee. mode and shift are categorical; distance_km and commute_min are quantitative.

DatasetOne row is…Rows
commuteone employee240
retail_weeklyone store in one week4,160
flight_delaysone scheduled flight departure2,500
engagement_populationone department6
campaign_funnelone marketing channel in one week130
Units of observation in some library datasets (all synthetic)

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.

  1. Unit of observation: one student (400 rows, 400 students).

  2. student_id — an identifier, categorical (and not analysed). school_type (Public, Private, International) — categorical. tutoring (true/false) — categorical with two values, often called binary.

  3. prior_score and exam_score — quantitative, recorded as whole points 0–100, so discrete in practice (though they measure an underlying continuous ability).

  4. study_hours_week and attendance_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

Not started

Classify each variable recorded by a hospital outpatient clinic.

Patient's blood type
Number of visits in the past year
Waiting time before being seen
Referring department
Body temperature
Number of prescribed medicines
Patient's medical record number

Exercise 2 · Practice, difficulty 1 of 3

What is one row?

Not started

Match each dataset to its unit of observation (what one row represents).

A table of each employee's typical commute (240 rows)
Weekly sales of 40 stores over 104 weeks
One record per scheduled departure at an airport
Survey headcount and responses for each of six departments
Clicks, leads and sales for each marketing channel each week

Exercise 3 · Practice, difficulty 1 of 3

Digits that are not numbers

Not started

Which of these variables are categorical even though they are written with digits? Select all that apply.

Select all that apply

Exercise 4 · Application, difficulty 1 of 3

Who was tutored?

Not started

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?

Not started

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

Not started

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?

Choose one

Exercise 7 · Interpretation, difficulty 3 of 3

Customers or transactions?

Not started

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.

0 words

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