Reproducible analyses in R, on a webpage

R
open science
meta
A first post showing how code, data, and results live together in a Quarto blog, with a small R example.
Author

Douglas A. Parry

Published

9 Jul 2026

This blog is written in Quarto, which means every post can contain real, runnable code. When I publish, Quarto executes the code and drops the results (tables, figures, models) straight into the page. Nothing is copy-pasted, so what you read is exactly what the code produced.

Here’s a tiny example. I’ll simulate some data on daily screen time and a well-being score, then plot the relationship.

set.seed(42)

n <- 200
screen_time <- rgamma(n, shape = 2, scale = 1.6)          # hours per day
wellbeing   <- 70 - 3.1 * screen_time + rnorm(n, 0, 6)    # arbitrary scale

d <- data.frame(screen_time, wellbeing)
head(d)
  screen_time wellbeing
1    5.838330  47.70299
2    1.420976  68.96039
3    2.494752  62.55328
4    0.723492  71.15898
5    2.196544  56.01376
6    1.284487  71.77570

A quick linear model:

fit <- lm(wellbeing ~ screen_time, data = d)
summary(fit)

Call:
lm(formula = wellbeing ~ screen_time, data = d)

Residuals:
     Min       1Q   Median       3Q      Max 
-15.6435  -4.8790   0.2777   4.7178  13.0123 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  69.6767     0.7788   89.47   <2e-16 ***
screen_time  -3.1250     0.2100  -14.88   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.245 on 198 degrees of freedom
Multiple R-squared:  0.5279,    Adjusted R-squared:  0.5255 
F-statistic: 221.4 on 1 and 198 DF,  p-value: < 2.2e-16

And the figure, with the code that draws it right above it in the source:

plot(d$screen_time, d$wellbeing,
     pch = 19, col = "#0077b388",
     xlab = "Screen time (hours/day)",
     ylab = "Well-being score",
     bty = "n")
abline(fit, col = "#005c88", lwd = 2)
Figure 1: Simulated association between daily screen time and a well-being score.

That’s the whole idea: the analysis and the write-up are one document. To add a post, I create a new folder under posts/, drop an index.qmd inside, and write. Because of freeze: true in posts/_metadata.yml, the code only re-runs when I change the post, so rebuilding the site stays fast even as the analyses pile up.