Memra

The first split, and the numeric-looking trap

◈ 6 cards

A variable is categorical or numeric; a numeric one is discrete (counted) or continuous (measured). Digits do not make a variable numeric — an ID is a label.

The first question to ask of any column

Before any summary, chart or R call, ask: is this variable categorical or numeric? A categorical (qualitative) variable puts each record into a group — a province, a channel, a product code. A numeric (quantitative) variable is a quantity you could sensibly add or average — an amount, a count of units. The test is not whether the cell contains digits; it is whether arithmetic on it means anything. The average of amount is a number with a meaning. The average of order_id is a number with none.

Numeric variables split once more. Discrete values are counted — units per order, orders per day, provinces served — and can only take separated values (3 units, never 3.4). Continuous values are measured on a scale where any value between two others is possible — a weight, a time, a distance. Money is the convention to learn: cents are technically counted, but amount in CAD is treated as continuous because the scale is fine enough that averaging, binning and fitting a line all behave as they would for a measurement.

Worked example — the six orders columns

ColumnTypeWhy
order_idcategorical (an identifier)digits, but a label — 1001 + 1002 means nothing
provcategoricalfour groups: ON, QC, BC, AB
channelcategoricaltwo groups: Online, Store
amountnumeric, continuousCAD; averaging is meaningful (511.67)
unitsnumeric, discretea count; 3, 1, 5 — never 3.4
order_datea dateits own type — Lesson 2.5

The row that catches people is the first. order_id looks numeric, sorts numerically, and Sheets will happily average it (=AVERAGE(A2:A13) gives 1006.5). But 1006.5 is not an order, and "the average order id rose in February" is not a finding. Identifiers, postal codes, SKUs and student numbers are categorical even when they are made of digits, because their arithmetic is meaningless.

In R the trap has a symptom: read.csv reads order_id as an integer column, so mean(orders$order_id) runs without complaint and prints 1006.5. The tool cannot tell an identifier from a count; you have to.

Six more columns

Postal code (N2L 3G1) — categorical: a label, even the digits. SKU (A100) — categorical. Star rating (1–5) — numeric-looking but, as Lesson 2.3 will show, better treated as ordered categories. HST rate (13 %) — numeric, continuous (a proportion). Headcount at a store — numeric, discrete (people are counted). Customer ID — categorical, an identifier. Then the pointed one: number of provinces served — numeric, discrete; it is a count of groups, not a group itself.

Why this decides everything after it

The type fixes the summary (counts for a categorical, mean or median for a numeric — Module 4), the chart (bar for categories, histogram for a numeric — Module 8), the pivot role (a categorical goes in Rows, a numeric in Values — Module 7) and the R class (chr or factor against num or int — Module 10). Get the type wrong and every downstream choice is wrong with it.

CRISP-DM: classifying each column is data understanding → describe data, and it is written into the dictionary in Lesson 2.4.

NORMAL ~/memra/learn/afm-112/categorical-numeric-discrete-continuous utf-8 LF