Day 15 — A short descriptive report
You send your supervisor a figure and one line: “treated plants grew more.” The replies come back: Which data file? How many plants? What are the dots? Did any values go missing? Can I rerun it? Every one of those questions is fair, and a short report can answer all of them at once. How do we write a report that a reader can understand, check, and regenerate?
Today you will:
This day pulls together Days 11–14. The same report becomes the starting point for the comparisons in week 4.
Question: how does seven-day growth vary among plants, and between control and treated seedlings?
data/seedlings.csv, 24 plants in separate pots, 12 per group, lengths in mm.descriptive-report.Rmd at the project root.> seedlings <- read_csv("data/seedlings.csv",
+ show_col_types = FALSE)
> anyDuplicated(seedlings$plant_id)
[1] 0
> seedlings |> count(treatment)
# A tibble: 2 × 2
treatment n
<chr> <int>
1 control 12
2 treated 12
> sum(is.na(seedlings$initial_mm))
[1] 0
> sum(is.na(seedlings$final_mm))
[1] 0
> seedlings <- mutate(seedlings,
+ growth_mm = final_mm - initial_mm)
anyDuplicated() gives 0: no plant ID is repeated.> group_summary <- seedlings |>
+ group_by(treatment) |>
+ summarise(n_observed = sum(!is.na(growth_mm)),
+ mean_mm = mean(growth_mm, na.rm = TRUE),
+ median_mm = median(growth_mm, na.rm = TRUE),
+ sd_mm = sd(growth_mm, na.rm = TRUE),
+ .groups = "drop")
> knitr::kable(group_summary, digits = 2)
|treatment | n_observed| mean_mm| median_mm| sd_mm|
|:---------|----------:|-------:|---------:|-----:|
|control | 12| 15.28| 15.65| 3.19|
|treated | 12| 21.49| 20.85| 4.87|
kable() prints this text; in the rendered report it becomes a neat table, rounded to 2 decimals.
The figure from Day 13, with a caption naming the unit, the symbols and n.
Supported: “Treated plants grew a mean of 21.5 mm and controls 15.3 mm (n = 12 each). Treated plants also varied more (SD 4.9 vs 3.2 mm), and the groups overlap.”
| Weak sentence | Repair |
|---|---|
| “The results were good.” | Name the pattern and its size. |
| “The treated group had more error.” | “Treated plants varied more (SD 4.9 mm).” |
| “Every treated plant grew more.” | False: the groups overlap. |
We described the sample. Estimating how uncertain the difference is comes in week 4.
A reader should be able to trace each number in the text back to a saved input and a chunk of code.
Inline R puts a calculated value straight into a sentence. In the source:
We measured `r nrow(seedlings)` plants.
renders as “We measured 24 plants.”
The object must be created earlier in the report. The sentence still needs units and meaning.
descriptive-report.Rmd at the project root, beside data/ and output/."data/seedlings.csv" means the same file on every computer that has the project.C:/Users/anna/Downloads/... works only on Anna’s laptop.output_dir puts the HTML into reports/.> rmarkdown::render("descriptive-report.Rmd", output_dir = "reports")
processing file: descriptive-report.Rmd
...
Output created: reports/descriptive-report.html
> list.files("reports")
[1] "descriptive-report.html"
.Rproj file does not contain the data. The CSV must travel with the report.The second class’s data, data/seedlings-transfer.csv, go into transfer-description.Rmd.
Reader review (code closed, HTML only)
Analyst review (source open)
Remove a redundant printout before you remove a unit label or a limitation.
| Concept | Key fact |
|---|---|
| Structure | Question → data and methods → results (table + figure) → interpretation and limitation |
| Input | Name the file; show checks for IDs, labels, missing values; state n (24 plants, 12 per group) |
| Results | Table from code (knitr::kable()), figure with plants and means, caption with n and units |
| Claims | Describe the sample (means 21.5 vs 15.3 mm, overlap, SD); no tested effect yet |
| Lineage | Every number traceable to data and code; inline R for counts and means |
| Location | .Rmd at project root; render from the Console with output_dir = "reports" |
| Fresh session | Restart R and render; test in a new folder; the data travel with the report |
| New study | Adapt the structure; replace every number, caption and sentence |
Next (Day 16, comparisons): turn the description into a comparison: state the question, the direction (treated − control) and the independent units before calculating a difference.
Now: open the Day 15 exercises. Leave with descriptive-report.Rmd (or organic-report.Rmd) and its rendered HTML, with the data needed to render it.