Read the data dictionary before the data, in R¶
Draft: not yet validated
The code on this page was run inside MESA RStudio Geospatial on 2026-11-16 (R 4.6.2), by the AI assistant that drafted it, and produced the output shown. No person has yet followed the steps, so a screen may differ. Tell us what you find.
A data dictionary is the table that says what each column means. Five minutes with it saves you from a number that looks right and is not.
You will: be able to say what one row of readings.csv is, and why its value
column cannot simply be added up across gauges.
Time: 5 minutes. You need: the readings and gauges tables from
Load a file from your Data Store in RStudio, in
MESA RStudio Geospatial.
Steps¶
-
Open the data dictionary for the practice data and read the four rows for
readings.csv.You should see: that one row is one reading, from one gauge, for one day.
-
Read the meaning of
valueagain, slowly.You should see: "in the gauge's own unit". The column does not promise one unit.
-
Find where the unit is recorded. Read the four rows for
gauges.csv.You should see: a
unitcolumn, one value for each gauge. -
In the Console, run:
gauges[c("gauge_id", "name", "unit")]You should see:
gauge_id name unit 1 G01 Boathouse mm 2 G02 Orchard cm 3 G03 Observatory mm 4 G04 Depot mm 5 G05 Quarry mm -
Compare the largest reading at each gauge:
tapply(readings$value, readings$gauge_id, max)You should see: G02's largest reading far below its neighbours'. The dictionary has already told you why: G02 reports in centimetres, the others in millimetres.
G01 G02 G03 G04 G05 24.90 2.92 32.50 26.40 180.00 -
In a script or a notes file, write one sentence of your own that says what
valueholds and what must happen before values from different gauges are compared.You should see: your sentence where a reader of your result can find it.
Check it worked¶
Without looking at this page, you can name the gauge that reports in a different unit and the file that told you so.
If it didn't¶
object 'gauges' not found. R has restarted since you loaded the files. Read them
again, as in Load a file from your Data Store in RStudio, then
repeat the step.
Next¶
- Check a column's range and missing values in R
- Bring two units onto one scale in R, which does the conversion the dictionary calls for.
- The same task in Python: Read the data dictionary before the data.
Not yet validated by a person in MESA RStudio Geospatial. Drafted with AI assistance on 2026-11-16; the code was run there that day (R 4.6.2).
Machine-readable versions of this page: Markdown twin · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.