Figure 2: A model of the data accounting for group membership: the outcome improves when more of the intervention is provided.
Source Code
---title: "OJS Demo"subtitle: "A demonstration of using OJS in Quarto documents"author: - name: "Andy Grogan-Kaylor" url: https://agrogan1.github.io/date: "today"format: html: theme: yeti code-fold: true code-summary: "Show the code" code-tools: true lightbox: true toc: true number-sections: true---# As An Example, Create The Data With R```{r}#| label: mydataintervention <-seq(1,15) # interventiongroup <-rep(LETTERS[1:5], each=3) # groupindex <-rep(seq(1,3), 5) # index within groupe <-rnorm(15, 0, .25) # randomly distributed erroroutcome <- index +-.1* intervention # + egroup <-factor(group)mydata <-data.frame(intervention, group, outcome)write.csv(mydata, "mydata.csv")```# Use OJS To Attach The Data```{ojs}mydata =FileAttachment("mydata.csv").csv({ typed:true })```# A First Simple Graph With OJS```{ojs}//| fig-cap: "A simple model of the data: the outcome gets worse as more of the intervention is provided."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}) ]})```# A More Complicated Graph With OJS```{ojs}//| fig-cap: "A model of the data accounting for group membership: the outcome improves when more of the intervention is provided."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}) ]})```