A demonstration of using OJS in Quarto documents

Author
Published

January 9, 2026

1 As An Example, Create The Data With R

Show the code
intervention <- seq(1,15) # intervention

group <- rep(LETTERS[1:5], each=3) # group

index <- rep(seq(1,3), 5) # index within group

e <- rnorm(15, 0, .25) # randomly distributed error

outcome <- index + -.1 * intervention # + e

group <- factor(group)

mydata <- data.frame(intervention, group, outcome)

write.csv(mydata, "mydata.csv")

2 Use OJS To Attach The Data

Show the code
mydata = FileAttachment("mydata.csv").csv({ typed: true })

3 A First Simple Graph With OJS

Show the code
Plot.plot({
  grid: true,
  color: {legend: false},
  symbol: {legend: true},
  marks: [
    Plot.dot(mydata, {x: "intervention", y: "outcome", fill: "black", r: 7, tip: true}),
    Plot.linearRegressionY(mydata, {x: "intervention", y: "outcome", strokeWidth: 3})
  ]
})
Figure 1: A simple model of the data: the outcome gets worse as more of the intervention is provided.

4 A More Complicated Graph With OJS

Show the code
Plot.plot({
  grid: true,
  color: {legend: false},
  symbol: {legend: true},
  marks: [
    Plot.dot(mydata, {x: "intervention", y: "outcome", r: 7, fill: "group", symbol: "group", tip: true}),
    Plot.linearRegressionY(mydata, {x: "intervention", y: "outcome", stroke: "group", strokeWidth: 3})
  ]
})
Figure 2: A model of the data accounting for group membership: the outcome improves when more of the intervention is provided.