| Variable | Type | Description |
|---|---|---|
| px_code | character | Participant code (randomly generated) |
| trial | integer | Trial number |
| item | integer | Item identifier |
| lifetime | factor | Lifetime status of referent: living or dead |
| tense | factor | Verb tense: present perfect or simple future |
| congruence | factor | Congruence between lifetime and tense |
| region | factor | Sentence region label: verb-1, verb, verb+1 to verb+4 |
| region_text | character | Text of the sentence region of interest |
| gaze | continuous | First-pass reading time (ms) |
| rpd | continuous | Regression path duration (ms) |
| tt | continuous | Total reading time (ms) |
| first_fix | continuous | First fixation duration (ms) |
| reg_in | binary | Regression into the region (0/1) |
| reg_out | binary | Regression out of the region (0/1) |
| rt_ms | continuous | Reaction time until plausibility rating (ms) |
| rating | ordinal | Plausibility rating (1 = implausible, 7 = plausible) |
| bio | character | Biographical sentence presented before the critical sentence |
| critical | character | Critical sentence presented to participants |
R for Publication
Reporting, Tables, and Figures for Academic Manuscripts
Preface
This workshop is a hands-on introduction to writing reproducible, publication-ready research documents in R and Quarto. Across two sessions, we’ll cover the full workflow from raw data to a formatted manuscript, including summary tables, model outputs, figures, citations, and export to HTML, PDF, Word and LaTeX.
Who this is for
Researchers with a working knowledge of R and the tidyverse who want to move from exploratory analysis to polished, reproducible manuscripts.
What you will learn
By the end of this workshop, you will be able to:
- Write and structure documents in Quarto using Markdown
- Export the same document to multiple formats (HTML, Word, PDF, LaTeX) with minimal format-specific tweaking
- Incorporate data directly into your text using inline reporting
- Produce publication-ready summary tables and model output tables
- Create and export figures with
ggplot2and cross-reference them in your manuscript - Manage code chunk options to control what appears in your output
Sessions
Day 1 focuses on the foundations: writing in Quarto, producing different output formats from a single source document, and bringing your data into the narrative through summary tables and inline reporting. This will be broken into the following chapters:
- Markdown basics: writing in Quarto
- Output formats: HTML, Word, PDF, and LaTeX
- Incorporating data: summary tables and inline reporting
Day 2 builds on this to cover the statistical reporting workflow: extracting and presenting model results, producing publication-ready figures, and tying everything together with cross-references. This will be broken into the following chapters:
- Reporting model results: model summary tables and inline reporting
- Producing figures: publication-ready plots, exporting, and cross-referencing
Tips on code chunk options are woven throughout both days.
How to use this book
Each chapter corresponds to roughly 30 minutes of workshop time. Code chunks are fully executable, work through them in your own RProject alongside the book. Each chapter also has accompanying slides (linked at the top) for the taught portion.
The dataset
The examples and exercises throughout this book use a real eye-tracking reading dataset based on Palleschi et al. (2025) (osf.io/6sra7), adapted for teaching purposes. The script used to adapt the data is included on the GitHub repository. The data comes from a self-paced reading study with a 2 × 2 factorial design, with lifetime (living vs. dead referent) and verb tense (present perfect vs. simple future) as independent variables.
The dataset has been preprocessed and restructured to more closely resemble data as it might arrive from a collection pipeline rather than fully cleaned analysis-ready data. It includes a randomly generated participant code column (px_code) — not real identifiers — to give you practice handling data that contains linkable information. Anonymisation of this column is covered in the second half of the book (Session 2 of the workshop).
The key variables are summarised in Table 1.
The verb region is the most theoretically relevant for the study’s hypotheses. Reading measures at this region are used in the exercises throughout Day 1 and Day 2. The rating variable is used in the tables chapter to illustrate frequency tables for ordinal data, and rt_ms provides an additional continuous outcome for practice.
Required software
Before the first session, please make sure you have the following installed:
- R (\(\geq\) 4.2): https://cran.r-project.org
- RStudio (\(\geq\) 2022.07): https://posit.co/download/rstudio-desktop
- Quarto (latest): https://quarto.org/docs/download
- TinyTeX (for PDF output) — see Installing TinyTeX below
Installing R, RStudio, and Quarto
Download and install each from the links above, following the instructions for your operating system. Install them in order: R first, then RStudio, then Quarto.
Installing TinyTeX
TinyTeX is a lightweight LaTeX distribution installable directly from R:
install.packages("tinytex")
tinytex::install_tinytex()Checking your versions
In the R console:
R.version.string
tinytex::is_tinytex()
tinytex::tlmgr("--version")In the Terminal tab:
quarto --versionRStudio’s version is visible under Help → About RStudio.
Updating
- R: download the latest version from https://cran.r-project.org
- RStudio: Help → Check for Updates
- Quarto: download the latest version from https://quarto.org/docs/download
- TinyTeX:
tinytex::tlmgr_update()
Packages
We’ll be using the pacman package to load and install required (CRAN) packages. As long as you have this package installed you should be able to run the example and exercise code.
install.packages("pacman")You only need to install pacman once. After that, pacman::p_load() handles loading and installing any missing packages automatically. Avoid leaving install.packages() calls uncommented in your scripts as they will re-run every time the script is executed or the document is rendered, which is slow and can cause unexpected package version changes. In other words, run this in the Console, or comment it out if you have it in a script.
Disclaimer
These materials were developed with the assistance of an AI language model (Claude, Anthropic) for outlining and editorial refinement using guided prompts. All content was fully reviewed, improved (I hope), and edited by the author. Every topic and reference included falls within the author’s own expertise; the use of AI assistance was a practical decision about time and effort, not a substitution for subject knowledge. Any errors, inaccuracies, or omissions are the author’s own responsibility.
These chapters also lean heavily on materials I previously created (without AI assistance) on R for Reproducibility, both in a semester-length course Open Science Practices: Implementing a Reproducible Analysis Workflow, a 4-day workshop Open Science Practices for Linguistic Research: Reproducible Analyses in R, and a 2-part workshop Reproducible Workflow in R. Unlike these previous materials which covered reproducibility and dynamic reports more broadly (and more in-depth), this book focuses on dynamic reports and reproducible analyses in the context of reporting results for publication and writing a manuscript in general.
An example prompt used for the slides for Output Formats:
let’s resturcture this to show how to render each format individually (only one in the yaml), shown in three columns where they have no options; then a slide on options (maybe just show toc: true for each); then a slide showing how to have them all in the yaml together in columns: left side where
: defaultis used, right side where you see the toc option as well; add a callout warning that indentation is very important