Skip to main content

1  Introduction to Quarto and Reproducible Publishing

Imagine that a health sciences student submits a report comparing sleep duration and stress. The report contains a table of means, a scatterplot, and a paragraph interpreting the results. A week later, the instructor discovers that one observation was entered incorrectly. The student corrects the spreadsheet, but must now remember which numbers, graphs, and sentences in the report depend on that observation. A document that looks polished can nevertheless conceal an unreliable production process.

Quarto offers a different approach: write the explanation and the instructions for generating evidence together, then render the source into a publication. This chapter introduces that approach before requiring any software installation. You can read the examples now and execute them after Chapter 2.

1.1 Learning objectives

After studying this chapter, you should be able to:

  • Distinguish reproducibility, replication, and computational correctness.
  • Explain the roles of source files, execution engines, and output formats.
  • Read a simple Quarto document and identify its metadata, prose, and code.
  • Choose an appropriate publishing workflow for a particular audience.
  • Explain how R and Python can generate evidence within a report.
  • Audit a small research report for dependencies, interpretation, and privacy.

1.2 Why reproducibility matters

A result is computationally reproducible when another person can obtain the reported computational result using the same inputs, methods, and relevant computing conditions. Replication is a different undertaking: it typically involves new observations or a new study addressing the same scientific question. A reproducible analysis can still be scientifically flawed. For example, a perfectly reproducible comparison of stress scores may be biased by selection of participants. Reproducibility makes the analysis inspectable; it does not establish validity by itself.

Consider a researcher who reports a mean of 21.2. The number alone does not reveal whether missing observations were excluded, whether an unusual observation was corrected, or whether the denominator was the number of patients or the number of visits. A useful research record makes these decisions visible. A collaborator should be able to trace the reported number back to the relevant observations and the computation that produced it.

1.2.1 The cost of manual synchronization

In a conventional workflow, the researcher imports data into an analysis program, copies a table into a word processor, exports a plot, and writes the interpretation. Each transfer creates an opportunity for inconsistency. A corrected table may coexist with an outdated plot. A manuscript revision may cite a sample size from an earlier analysis. These problems are especially difficult to detect when the output looks reasonable.

In a computational workflow, the source describes both the analysis and its presentation. Rendering regenerates the computational outputs, subject to the execution settings and available dependencies. Narrative interpretations still require human review: a sentence claiming that a relationship is positive does not automatically become scientifically correct when a new dataset produces a negative slope.

Two publishing workflows: manual transfer versus a shared computational source.
Figure 1.1: Two publishing workflows: manual transfer versus a shared computational source.

The distinction in Figure 1.1 is not between good and bad software. A spreadsheet or word processor can be used responsibly. The distinction is whether the transformations from inputs to published evidence are explicit, repeatable, and maintained together.

ImportantReproducibility is a property of a workflow

A .qmd extension does not guarantee reproducibility. Data access, package versions, random seeds, file paths, and analytical decisions must also be managed.

1.2.2 A small audit

Suppose a report says that 60% of participants slept at least seven hours. To audit the statement, ask what counts as a participant, how sleep was measured, which records were eligible, whether missing values were excluded, and how the percentage was rounded. These questions are relevant even before opening a computer. The computational document should preserve enough information to answer them.

1.3 What Quarto is—and what it is not

Quarto is an open-source scientific and technical publishing system. It converts structured source documents into outputs such as HTML, PDF, Word documents, and presentations. It can also organize multiple documents into a website or book. A source document may contain only prose, or it may contain executable code. See the official documentation (Quarto, n.d.).

Quarto is not a statistical programming language. R and Python perform computations; Quarto coordinates their inclusion in a publication. Nor is Quarto a replacement for careful study design, data cleaning, or editorial judgment. It helps communicate these activities in an organized form.

1.3.1 The publishing ecosystem

Component Responsibility Example
Markdown Express document structure A second-level heading
YAML Specify metadata and options Select HTML output
R or Python Perform computation Calculate a mean
knitr Execute supported computational chunks Evaluate R code
Jupyter Execute code through a kernel Evaluate Python code
Pandoc Convert structured documents Produce a Word document
Quarto Coordinate publishing Render a report or book

A useful mental model is a publishing pipeline. The source is read, computations are evaluated when enabled, and the resulting document is transformed into the requested format. The exact stages depend on the execution engine and output format. For instance, PDF generation through LaTeX requires an appropriate TeX installation, while ordinary HTML does not.

1.3.2 Source versus output

The source file is the editable record of what you intend to publish. The output file is a generated representation for a particular audience. Edit the source rather than repeatedly modifying generated HTML or PDF files. Otherwise the next render can overwrite your changes.

A collaborator who needs to inspect the analysis may need the source, data, and environment information. A reader who simply needs the conclusions may only need the PDF. A public reader may need an HTML page without access to confidential data. These are different distribution decisions, not different definitions of the analysis.

1.4 Comparing publishing tools

Tool Useful when Consideration
Word Collaborators need tracked changes Computations may be maintained separately
LaTeX Precise mathematical typesetting is central Computation requires additional integration
Jupyter Notebook Exploratory code and immediate output matter Execution order and hidden state need attention
R Markdown Existing R-based workflows are established Migration is not always necessary
Quarto Multiple formats or structured computational publications are needed Rendering dependencies must be managed

The best choice depends on the task. A journal that requires a particular Word template may still accept a manuscript initially generated with Quarto. A mathematician may prefer a specialized LaTeX workflow for a proof-heavy monograph. A researcher may explore data in a notebook before preparing a Quarto report. These tools can coexist.

1.5 Anatomy of a Quarto document

The following is a complete minimal source file. Save it as first-report.qmd when you have installed Quarto.

---
title: "My First Research Report"
author: "Your Name"
format: html
---

## Research question

How much sleep do students report?

## Conclusion

This report introduces a descriptive investigation.

The opening and closing lines of three hyphens delimit YAML metadata. The title and author describe the publication. The format specifies HTML. The remainder is Markdown prose. Two hash marks introduce a second-level heading. Blank lines separate paragraphs.

1.5.1 Metadata and indentation

YAML is a structured configuration language. Indentation indicates nesting. The following example requests two output formats and a table of contents in HTML.

format:
  html:
    toc: true
  docx: default

Here toc belongs to html, not to docx. Use spaces rather than tabs for indentation. A colon followed by a space separates a key from its value. Quoting a title containing a colon avoids ambiguity. Chapter 3 develops these rules systematically.

1.5.2 Displayed code versus executable code

A fenced block labeled r displays R code. A block labeled {r} requests execution by an appropriate engine. The difference matters when writing a tutorial: sometimes the purpose is to show an example without executing it, particularly if it installs software or modifies files.

```{r}
mean(c(7, 6, 8, 7, 5))
```

The output is 6.6. The computation is simple enough to verify by hand, but the principle scales to a lengthy analysis. If the input changes, the result is regenerated when the document is executed again.

1.6 Worked investigation: student wellness

The following five records are synthetic and are included solely for instruction. Each row represents one fictional student. Sleep and study time are measured in hours; stress is an illustrative numerical score, not a validated clinical measure.

Table 1.1: Synthetic student wellness observations.
Student Study hours Sleep hours Stress score
1 3 7 18
2 5 6 24
3 2 8 15
4 4 7 20
5 6 5 29

Our question is descriptive: what is the average reported sleep duration, and what pattern is visible between sleep and stress in these five records? We do not intend to estimate a population effect or establish causation.

The arithmetic mean is

\[ \bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i. \]

For sleep duration, the numerator is 33 hours and the denominator is five students. Thus the mean is 6.6 hours. Three students report at least seven hours, giving a proportion of 3/5 = 0.60. The threshold is an illustrative analytical choice, not a clinical recommendation.

1.6.1 R implementation

The companion file examples/ch01/wellness-r.qmd contains an executable R report. The code below uses base R so no additional analysis package is required. Run it from the project root when using the console.

wellness <- read.csv("data/student-wellness.csv")
stopifnot(!anyNA(wellness$sleep_hours))
n <- nrow(wellness)
mean_sleep <- mean(wellness$sleep_hours)
prop_seven <- mean(wellness$sleep_hours >= 7)
print(c(n = n, mean_sleep = mean_sleep,
        proportion = prop_seven))

read.csv() imports the observations as a data frame. The dollar sign selects a named column. The comparison produces logical values; their mean is the fraction that are true. The explicit missing-value check prevents the example from silently changing its denominator if the dataset is modified.

Expected output: five observations, mean sleep 6.6 hours, and proportion 0.60.

plot(wellness$sleep_hours, wellness$stress_score,
     xlab = "Sleep duration (hours)", ylab = "Stress score",
     pch = 19)

1.6.2 Python implementation

The corresponding executable report is examples/ch01/wellness-python.qmd. This example uses Python’s standard library for the numerical summary; plotting requires Matplotlib.

import csv
from statistics import mean

with open("data/student-wellness.csv", newline="") as f:
    records = list(csv.DictReader(f))
sleep = [float(row["sleep_hours"]) for row in records]
stress = [float(row["stress_score"]) for row in records]
print(len(sleep), mean(sleep),
      sum(x >= 7 for x in sleep) / len(sleep))

DictReader associates each field with its column name. CSV values initially arrive as strings; float() converts them to numerical values. The generator expression counts the records satisfying the threshold. The result agrees with R because the same observations and definition are used.

import matplotlib.pyplot as plt
plt.scatter(sleep, stress)
plt.xlabel("Sleep duration (hours)")
plt.ylabel("Stress score")
plt.show()
Scatterplot of the five synthetic observations.
Figure 1.2: Scatterplot of the five synthetic observations.

The scatterplot suggests that higher sleep duration accompanies lower stress in these records. With only five synthetic observations, the pattern is illustrative. It does not justify a causal conclusion or a population-level estimate. A reproducible report should make that limitation as visible as the graph itself.

1.6.3 Updating the analysis

Suppose student 5’s sleep duration was corrected from five to six hours. The new total is 34 and the mean becomes 6.8. The proportion at or above seven hours remains 0.60. This is a useful example because not every output changes after a correction. A report author should inspect both changed and unchanged results rather than assuming that all summaries move together.

The accompanying reports calculate the summaries directly from the CSV file. They use separate R and Python documents to avoid introducing mixed-engine configuration before readers have learned the basics. The book chapter displays code and verified illustrative figures; it does not require both languages to execute during book rendering.

1.7 Rendering and publication formats

Rendering is the act of producing a publication from its source. Previewing is a convenient way to inspect a publication during editing. In a terminal, after installation, the command quarto render first-report.qmd --to html requests an HTML output. quarto preview first-report.qmd starts a preview session. The exact editor interface varies, but the underlying source remains portable.

Format Typical audience Strength Limitation
HTML Students and online readers Navigation and interactive features Requires a browser
PDF Print readers and reviewers Stable page layout Limited web interactivity
DOCX Collaborators and editors Familiar editing workflow Layout may change across applications
EPUB E-reader users Reflowable text Complex layouts may need adaptation
Reveal.js Presentation audiences Browser-based slides Requires presentation-specific design

A single source can support multiple formats, but not every feature translates identically. An interactive slider may need a static figure in print. A wide dashboard may require a different layout for a narrow screen. Inspect each target format instead of assuming that successful HTML rendering guarantees a good PDF.

1.8 Reproducibility beyond the document

1.8.1 Data and paths

An absolute path such as C:/Users/Researcher/Desktop/study.csv refers to a specific computer. A project-relative path makes a project easier to move, provided that the working directory is defined consistently. The companion reports use paths relative to their own location. The console examples assume the project root. These are explicit conventions, not interchangeable assumptions.

1.8.2 Software environments

A package update can change a default, remove a function, or alter a numerical algorithm. Record the relevant software versions. In R, sessionInfo() describes the session; in Python, sys.version identifies the interpreter. Later chapters introduce dependency management. A version record is useful evidence but is not itself a complete environment lockfile.

1.8.3 Randomness and hidden state

Simulation and random sampling may yield different results each time. A documented seed can make a particular random sequence repeatable under appropriate conditions. R’s set.seed() and Python’s random.seed() are examples for their respective random generators; other libraries may use separate generators. A seed does not make a simulation scientifically valid, nor does the same seed guarantee identical results across languages.

A notebook may contain variables created by running cells out of order. A clean render is a valuable test because it exposes dependencies on objects that exist only in an interactive session. Avoid relying on a previously loaded workspace.

1.8.4 Privacy and responsible publication

Reproducibility does not mean that all data must be publicly released. Clinical records and student information may be restricted. A public project can include synthetic data, a data dictionary, analysis code, and instructions for authorized access to restricted inputs. Do not place identifiers, credentials, or confidential data in a public repository. Removing names alone may not eliminate re-identification risk. Follow applicable institutional policies and approvals.

1.9 Guided practice

1.9.1 Activity 1: Audit a conventional report

A colleague sends a PDF with a table of patient recovery times and a graph but no data or analysis instructions. Write four questions you would ask before attempting to reproduce the reported mean. Distinguish questions about computation from questions about study validity.

1.9.2 Activity 2: Read the source

Using the minimal document above, identify the metadata boundaries, title, output format, and two headings. Predict what would happen if the title changed but the prose remained unchanged. Explain why editing the generated HTML is not the preferred way to make that change permanent.

1.9.3 Activity 3: Investigate a data correction

Copy the five-row dataset before editing it. Change student 5’s sleep duration to six hours. Calculate the mean and threshold proportion by hand. After Chapter 2, render a copy of either companion report against the modified dataset and compare the output with your prediction. Restore the original data before continuing.

1.9.4 Activity 4: Choose a publication format

A faculty member needs a searchable course resource, a journal collaborator needs an editable manuscript, and a conference presenter needs slides. Recommend a format for each and explain one feature that might require format-specific adjustment.

1.10 Troubleshooting and diagnostic reasoning

Symptom First diagnostic step Reason
Quarto command not found Check installation and terminal PATH The CLI may not be available
YAML parsing error Inspect indentation and punctuation Metadata must be valid before rendering
File not found Check working directory and relative path A valid filename can resolve incorrectly
Missing Python module Check the interpreter used for rendering Packages may be installed elsewhere
R object not found Inspect preceding code and clean-session behavior Interactive state may hide a dependency
PDF render fails Inspect the first relevant TeX error HTML success does not verify PDF dependencies
Old numbers appear Check execution, caching and input paths Output may not reflect the intended inputs

When troubleshooting, change one thing at a time and retain the original error message. A minimal example that reproduces the problem is often more useful than a large project with many unrelated settings. Do not suppress errors merely to obtain a visually complete document.

1.11 From a scientific question to a reproducible publication

A publication is the final stage of a chain of decisions, not simply a container for results. Before opening a code editor, identify the question, the observational unit, the measurements, and the intended audience. A study of clinic waiting times might ask whether a scheduling change reduces delays. A descriptive report of waiting times from one week, however, cannot answer that causal question by itself. It can establish a baseline, identify unusually long waits, and motivate a better-designed investigation. The scope of the conclusion must match the scope of the evidence.

A useful source document preserves four distinct layers: the evidence (data and its provenance), the transformation (code and analytical decisions), the interpretation (what the results mean), and the presentation (the output format). Each layer has a different failure mode. An incorrectly entered observation is an evidence problem; a wrong denominator is a transformation problem; a causal claim from an observational comparison is an interpretation problem; a clipped axis label is a presentation problem. Changing the theme cannot repair a wrong denominator. Correcting the denominator cannot justify a causal conclusion. This separation is the basis of systematic troubleshooting throughout this book.

1.11.1 Worked example: the denominator is a scientific decision

A fictional clinic records eight scheduled appointments. Six patients arrive, and five have recorded waiting times of 8, 12, 15, 20, and 25 minutes. One arriving patient has no recorded waiting time. Two scheduled patients do not arrive. The question is: what proportion of arriving patients with a recorded wait experienced a delay of at least 15 minutes?

The numerator is three, and the denominator is five, giving \(3/5=0.60\). Dividing by eight instead would give 37.5%, a different quantity that treats absent and unmeasured patients as if their delays were known. Dividing by six gives 50%, which implicitly counts the missing wait as not meeting the threshold. Neither alternative answers the stated complete-record question. The report should disclose that one of six arriving patients lacks a measurement. If that patient’s waiting time were below 15 minutes, the proportion among all arriving patients would be 3/6; if at least 15 minutes, it would be 4/6. Thus the available evidence bounds the all-arrivals proportion between 50% and approximately 66.7%, without assuming a missingness mechanism.

This example illustrates why a denominator belongs in the source document’s explanation as well as its code. A reproducible report records the inclusion rule, the threshold, the count of missing observations, and the exact computation. A reader can then assess whether the rule is appropriate, rather than merely verify arithmetic.

1.11.2 Guided investigation: trace the claim

For the clinic example, write a sentence describing the population actually observed, a sentence specifying the inclusion rule, and a sentence reporting the result. Then identify the evidence needed to support a claim that the scheduling system caused the delay. Consider whether a comparison group, random assignment, or adjustment for appointment type might be relevant. These are design questions, not features that a publishing system can automatically resolve.

1.12 Worked investigation: a corrected clinic report

The following synthetic data represent six visits in each of two clinic sessions. The recorded waiting time is the interval between check-in and the beginning of the consultation. The two sessions are illustrative, not randomized treatment groups.

Table 1.2: Fictional clinic waiting times.
Visit Session A (minutes) Session B (minutes)
1 12 9
2 18 14
3 15 11
4 21 16
5 24 18
6 30 22

Let \(x_{gi}\) denote the waiting time for visit \(i\) in session \(g\). The arithmetic mean is

\[ \bar{x}_g=\frac{1}{n_g}\sum_{i=1}^{n_g}x_{gi}. \tag{1.1}\]

For session A the sum is 120 minutes, giving a mean of 20 minutes. Session B has a sum of 90 minutes and a mean of 15 minutes. The observed difference, B minus A, is \(15-20=-5\) minutes. This is a descriptive contrast between the recorded sessions, not an estimated causal effect of a scheduling intervention. Different appointment types, staffing levels, or patient needs could explain the contrast.

Individual waiting times in each fictional clinic session; diamonds indicate group means.
Figure 1.3: Individual waiting times in each fictional clinic session; diamonds indicate group means.

The dot plot in Figure 1.3 preserves individual observations. A bar chart of means alone would hide the spread of the waits. The maximum wait is 30 minutes in A and 22 minutes in B, so the distinction between sessions is not limited to their means. Nevertheless, twelve observations provide limited information about the variability of future sessions.

1.12.1 R implementation

The following code is displayed rather than executed in the book. The standalone companion report executes the same calculations using a CSV file.

A <- c(12, 18, 15, 21, 24, 30)
B <- c(9, 14, 11, 16, 18, 22)
mean(A)
mean(B)
mean(B) - mean(A)

R returns 20, 15, and -5. The vectors represent groups, and mean() computes their arithmetic means. The subtraction order is deliberate: a negative difference means the observed mean in B is lower than in A.

1.12.2 Python implementation

from statistics import mean
A = [12, 18, 15, 21, 24, 30]
B = [9, 14, 11, 16, 18, 22]
print(mean(A), mean(B), mean(B) - mean(A))

Python returns the same three values. Agreement between languages is a useful check on this simple computation, but it is not proof that the data are accurate or that the comparison is scientifically appropriate. Both implementations could faithfully reproduce an incorrect input.

1.12.3 Correcting an observation

Suppose a source record confirms that the last wait in A was 20 minutes rather than 30. The corrected sum is 110, and the mean is \(110/6\approx18.33\). The new B-minus-A difference is approximately -3.33 minutes. A report that updates only the table but leaves a five-minute difference in the discussion is internally inconsistent. A report that updates the code and figure but retains an outdated prose claim is also inconsistent.

Keep the original data in a restricted or otherwise appropriate archival location, record the reason for the correction, and use a new version of the analysis input. Do not silently overwrite the only copy of the original evidence. In the companion exercise, both versions are synthetic and can safely be distributed. Real clinical records require authorized storage and access controls.

1.12.4 Guided investigation: sensitivity to a single record

Calculate the median of each session before and after the correction. For A the original ordered values are 12, 15, 18, 21, 24, 30, so the median is 19.5. After correction they are 12, 15, 18, 20, 21, 24, giving 19. The median changes by only 0.5 minutes, while the mean changes by approximately 1.67 minutes. This is an illustration of sensitivity, not a general claim that medians are always preferable. The choice of summary should reflect the scientific question and distribution.

1.13 Designing a source document for its readers

A research collaborator may want to see every computation; a student may benefit from seeing the formula and a small code example; a clinical audience may need a concise interpretation with a clear figure. A reproducible source can support these different audiences without creating independent, manually synchronized analyses. The author still needs to decide what each audience should see. Hiding code in an HTML report, for example, changes its presentation, not necessarily its execution. Code folding allows readers to expand a block, whereas excluding code from the rendered output removes that block from view. Neither technique is a security control: source files and embedded resources must be reviewed separately before public distribution.

1.13.1 A publication planning matrix

Audience Main question Evidence to show Output choice
Clinical team How long are patients waiting? Counts, individual values, summaries HTML or PDF report
Methods reviewer How were results obtained? Inclusion rules, code, dependencies Source plus report
Student How is a mean calculated? Formula, worked example, practice HTML lesson or worksheet
Journal editor Is the manuscript ready for review? Structured prose, figures, references Required journal format

The matrix is not a rigid rule. A clinical team might prefer a printed handout, and a reviewer might request an executable notebook. Determine the delivery requirements before designing the source. In particular, a browser-based interactive widget may have no meaningful direct equivalent in a printed document. Provide a static figure and explanatory text when the printed edition is important.

1.13.2 Worked example: a publication specification

Suppose an instructor wants to distribute a lesson on waiting times as an online resource and a printable worksheet. The lesson needs an explanation of the mean, a small synthetic dataset, R and Python code, and two exercises. The HTML edition can use a table of contents and collapsible code; the PDF edition should have adequate margins and room for student work. Both editions must agree on the numerical answers. A sensible plan is to maintain a common source for the explanation and computations, use format-specific settings for layout, and maintain a separate instructor-only solution file. Do not publish the solution file as a public website resource if it is intended to be restricted.

1.14 A first reproducibility audit protocol

Imagine receiving a report from a colleague who is leaving the research team. The report is attractive, but you must update it next semester. Before attempting a full render, create a copy of the project and inventory its contents. Identify the entry point, the input files, the execution engine, the expected output, and the software dependencies. Ask whether any files are missing or accessible only through a personal account. A project that depends on a private absolute path or an undocumented spreadsheet is not portable simply because it rendered on its author’s computer.

Next, record the baseline: the input version, the expected number of observations, and two or three numerical results that can be independently checked. Run the analysis in a fresh session. Compare the new outputs with the baseline, allowing for documented numerical tolerances when appropriate. Inspect figures, tables, citations, and conclusions. Finally, record what was tested, what failed, and what remains unverified. A successful execution is evidence about the tested environment, not a guarantee about every possible computer or future package version.

1.14.1 Audit evidence record

Check Evidence to retain Acceptance condition
Input identity Filename, version, provenance Intended input is available
Data validation Row counts, missing counts, units Matches documented expectations
Numerical check Independent calculation Agrees within stated tolerance
Clean execution Render command and log No unresolved errors
Output inspection Reviewed output and notes Claims and displays agree
Privacy review Access and distribution decision No unauthorized disclosure

A checksum can help identify whether a file has changed, but it cannot establish that the file is scientifically correct. Likewise, a passing automated test can verify an expected mean while missing a biased sampling process. Use automated and human review together.

1.15 Extended practice and case studies

1.15.1 Case study 1: a missing sleep measurement

A student wellness report contains sleep durations of 7, 6, 8, 7, and one missing value. The analyst reports that 60% of students sleep at least seven hours. Identify the numerator and both plausible denominators. Calculate the complete-record proportion and explain why treating the missing value as a short sleep duration is unjustified. Write a revised result sentence that reports missingness explicitly.

1.15.2 Case study 2: a changed threshold

A clinic report defines a long wait as at least 20 minutes. A supervisor requests a threshold of at least 15 minutes instead. Using session A in Table 1.2, calculate both proportions. Identify every component of the report that might depend on the threshold, including titles, captions, and prose. Explain how defining the threshold once in code reduces the risk of inconsistent calculations, and why prose still requires review.

1.15.3 Case study 3: a portable project

A collaborator sends report.qmd and a screenshot of a graph. The report reads a file at C:/Users/Analyst/Desktop/clinic.csv. Design a portable folder structure and describe what additional files and instructions are required. Explain how you would share the project if the CSV contained restricted patient information.

1.15.4 Case study 4: conflicting results

Two analysts obtain different means from apparently identical datasets. One reports 18.33 and the other reports 20.00. Use the clinic correction example to propose a sequence of checks before concluding that either programming language is wrong. Include input identity, inclusion rules, units, missing values, and rounding in your investigation.

1.15.5 Case study 5: a publication format failure

An HTML lesson renders correctly but its PDF version fails. Explain why this does not necessarily indicate an error in the statistical analysis. Identify the separate roles of the execution engine and the PDF conversion system. Propose a minimal document that would help isolate a PDF-specific problem.

1.15.6 Extended project: a reproducibility handoff

Create a small project using the clinic dataset supplied with this chapter. Prepare a source report, a data dictionary, a correction log, and a README explaining how to reproduce the analysis. Use either R or Python to calculate group counts, means, medians, and the B-minus-A mean difference. Include a dot plot and an interpretation that distinguishes descriptive evidence from causal inference. Produce an HTML edition after completing Chapter 2. Ask a peer to follow the README in a clean copy of the project; record any missing instructions and revise them. Submit the original and corrected summaries together with the evidence of your review.

Criterion Points
Clear question, units and inclusion rules 5
Accurate calculations and readable figure 8
Documented correction and updated interpretation 6
Portable project and reproducibility instructions 6
Peer audit and response to feedback 5
Total 30

1.16 Chapter summary

Quarto coordinates structured authoring, computation, and publication. Its value lies in making the relationship between evidence and communication explicit. Markdown describes structure, YAML configures the publication, execution engines evaluate code, and conversion tools generate the selected format. A reliable workflow also requires appropriate data access, documented dependencies, clean execution, and careful interpretation.

1.17 Review exercises

  1. Define computational reproducibility and distinguish it from replication.
  2. Explain why a reproducible result can still be scientifically misleading.
  3. Identify two risks of copying numerical outputs manually into a report.
  4. Explain the difference between Quarto and R.
  5. Describe the roles of YAML and Markdown.
  6. Distinguish displayed code from executable code.
  7. Explain why a PDF and its source file serve different purposes.
  8. Calculate the mean study time in Table 1.1.
  9. Calculate the proportion with stress scores above 20.
  10. If student 2’s sleep changes from six to seven hours, calculate the new mean and threshold proportion.
  11. Explain why the scatterplot cannot establish causality.
  12. Identify an appropriate format for a collaborative manuscript and a searchable course website.
  13. Rewrite an absolute file path as a plausible project-relative path and state the working-directory assumption.
  14. Explain why setting a seed is insufficient to document an entire computational environment.
  15. Describe a responsible way to share analysis code for restricted patient data.
  16. A report renders successfully on one computer but not another. Propose a diagnostic sequence involving software versions, data paths, and execution engines.

1.18 Applied project: a reproducible wellness report

Prepare a short descriptive report using the supplied synthetic dataset. You may complete the planning portion now and the rendering portion after Chapter 2. Choose R or Python; using both is optional.

Your report should include a research question, a description of the observational unit, the data source and its synthetic status, a numerical summary of sleep duration, the proportion meeting the illustrative threshold, a labeled scatterplot, and a cautious interpretation. Include the source file and the generated HTML output. Record the software environment and explain how another reader could reproduce the report. Finally, describe the change you would expect if one observation were corrected.

Assessment criterion Points
Clear question and data description 4
Correct reproducible computations 6
Accurate and readable figure 4
Appropriate interpretation and limitations 4
Organized source and reproduction instructions 4
Evidence of a clean render and correction check 3
Total 25

1.19 Further reading

Consult the Quarto authoring tutorial for editor-specific instructions and the Quarto guide for an overview of publication features. The next chapter introduces installation, configuration, and the first complete rendering workflow.

1.20 Supplemental assessment

  1. Conceptual (4 points). Distinguish a source document, an input dataset and a rendered artifact.
  2. Technical (8 points). For waits 10, 12, 15, 18, 25, calculate mean and median. Replace 25 by 35 and repeat.
  3. Applied (8 points). Prepare a handoff folder for a clinic report; specify three acceptance tests.

See the student assessment packet in the source package for submission guidance and any required datasets.

1.21 Looking ahead

Install and verify the tools needed to execute the examples in Chapter 2.

1.22 Interactive learning lab

Explore the activity below, then explain what changed and why.

Open the activity in its own page.