Every analysis begins with an act of trust it has not earned.
A file arrives — from a till system, a warehouse, a colleague, a download — and the analyst reads it in. In R, `read_csv()` will happily build a beautiful table from a broken file. It will guess column types, swallow odd values into `NA`, and say nothing at all about rows that are exact copies of other rows. No error appears. The analysis begins. And everything built on top of that silent moment inherits whatever was wrong with it.
Reading data in is therefore not a clerical step before the analysis. It is the first analysis — of the file itself.
The read is one line; the discipline is what follows
The workhorse is `read_csv()` from the readr package, part of the tidyverse. It reads a comma-separated file, guesses each column's type from its contents, and returns a tibble — the tidyverse's table, which prints its dimensions, shows column types under the column names, and refuses several of the silent behaviors that make ordinary data frames dangerous.
Its siblings cover the rest of working life: `read_excel()` from readxl for spreadsheets, where you name the sheet and never assume the first one holds the data; `read_tsv()` for tab-separated exports; `read_csv2()` where semicolons separate fields and commas serve as decimal marks. Whatever the reader, the discipline is identical: say the file, say the object, then inspect before you believe.
Inspection has an order, and the order matters
First, shape. `dim()` and the tibble's own header tell you the rows and columns — and you compare them against what the sender claims the file holds. A truncated export announces itself here, if anywhere.
Second, names. `names()` shows exactly what the columns are called, including the surprises: a trailing space, a renamed field, two columns that differ only by a suffix the export added.
Third, types. `glimpse()` shows every column with its type and first values, and this is where the classic ambushes live. A revenue column read as character because one cell holds `$1,240` will sort beautifully and sum not at all. A date stored as text will sort January, October, November in cheerful alphabetical order. An ID read as a number loses its leading zeros and stops matching anything it was supposed to join to.
Fourth, contents. `summary()` for the numeric columns, counts of the categorical ones, and a deliberate hunt for missing values — `sum(is.na(...))` per column. In R, `NA` is not zero, not blank, and not ignorable. It is a value that propagates, quietly turning sums into `NA` until you decide, explicitly, what missing means in this dataset.
Fifth, uniqueness. Does the column that should identify a row actually identify it? `sum(duplicated(orders_raw$order_id))` is a one-line audit that has saved more analyses than any model.
What inspection finds in a real file
Consider the running example used throughout the course: a fictional specialty-foods retailer whose order system exports one row per order for its just-ended year. The export holds 10,250 rows. Inspection reveals that 250 of them are exact duplicates. Remove them and 10,000 unique orders remain.
Of those, 500 are canceled orders — never billed, never shipped — and 500 are returned orders whose $30,000 of billed amount came back. What remains is the analysis table: 9,000 fulfilled, kept orders totaling $540,000, an average order of exactly $60.
The companion customer file carries its own flaw: 40 customer IDs appear twice, so its 2,540 rows describe 2,500 unique customers, and one date column is missing for 125 of them — 5 percent. None of this was announced by the read. All of it was findable in minutes by an analyst who inspected before believing. And the cleaned table can be reconciled four different ways — by category, by region, by month, by customer segment — each cut summing to the same 9,000 orders and the same $540,000. That is what a dataset looks like when it is safe to summarize.
There is a second lesson in those numbers. The distance between the raw export and the analysis table — 10,250 rows down to 9,000, with canceled and returned orders accounted for rather than silently dropped — is not bookkeeping trivia. It is the difference between reporting revenue that includes money which came back, and reporting revenue the business actually kept. Every later step in the workflow, from tidy data to grouped summaries to a first model, assumes this distance has been measured and can be explained. An analyst who cannot walk from the raw file to the analysis table, number by number, does not yet know what their own results describe.
The misconception that starts bad analyses
It sounds reasonable: "If `read_csv()` ran without an error, the data is in and I can start analyzing."
A clean run means the file was parseable. It does not mean the file was truthful. Duplicates parse beautifully. Text-typed money parses beautifully. A missing sheet, a truncated export, and a column of IDs stripped of their leading zeros all parse beautifully. The read is the moment of maximum danger precisely because it so rarely complains.
Inspection is not paranoia after the read. Inspection is the read, finished. Shape, names, types, contents, uniqueness — five checks, in order, every time, before the first summary is computed or the first chart is drawn. The analyst who builds that reflex spends minutes at the start of a project instead of days at the end of one, explaining why the numbers never reconciled.
Experience it, don’t just read about it
Reading a file in as the first analysis — inspecting shape, names, types, contents, and uniqueness before believing any of it — is Concept 2 of Data Analysis with R (Course No. 130), from Cognosco Learning, a learning company powered by AI. The course builds the full analytical workflow beyond this distinction — Tidy Data, Grouped Summaries, and Checking Your Work — each worked through with an Agentic Socratic AI coach, one learner at a time. Try a Free Preview at cognoscolearning.com.
Navigate your own course.
© 2026 Cognosco Learning. All rights reserved.