Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.1 — Kinds of Data
Data Visualization · Example 1 of 2

Tag each Lumen column with its kind

Time and ordinal data can be sorted, but only quantitative data is averaged. Categorical data can only be counted and grouped.

Data comes in four kinds: quantitative (amounts), ordinal (ordered labels), categorical (unordered labels) and time. The kind decides what you may do with a column: sort it, average it, compare it, or only count it.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write isNumberColumn(values) that returns true only if every non-empty value converts to a finite number and none starts with a zero followed by another digit (like "07790"). Test with ["12", "20"], ["07790", "09250"], ["S01", "S02"].

02

Write meanOf(values) for an array of strings that returns the mean of the numeric ones, skips empty strings and "n/a", and returns null when nothing numeric is left. Test with ["1539", "1519", "1950", "", "1915"] and ["", "n/a"].

Explain it without notes

01

Name the four kinds of data and one Lumen column for each.

02

Why is a station ID such as S01 not a number even though it contains digits?

03

Why is a missing value not the same as zero? Give a Lumen example.

Tag each Lumen column with its kind

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

id (categorical): never average this
name (categorical): never average this
district (categorical): never average this
opened (time): never average this
weekday (ordinal): never average this