<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Douglas A. Parry</title>
<link>https://dougaparry.com/blog.html</link>
<atom:link href="https://dougaparry.com/blog.xml" rel="self" type="application/rss+xml"/>
<description>Media psychologist studying digital media, cognition, and well-being.</description>
<generator>quarto-1.9.38</generator>
<lastBuildDate>Thu, 09 Jul 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Reproducible analyses in R, on a webpage</title>
  <dc:creator>Douglas A. Parry</dc:creator>
  <link>https://dougaparry.com/posts/welcome/</link>
  <description><![CDATA[ 




<p>This blog is written in <a href="https://quarto.org">Quarto</a>, 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.</p>
<p>Here’s a tiny example. I’ll simulate some data on daily screen time and a well-being score, then plot the relationship.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>)</span>
<span id="cb1-2"></span>
<span id="cb1-3">n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span></span>
<span id="cb1-4">screen_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rgamma</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scale =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>)          <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># hours per day</span></span>
<span id="cb1-5">wellbeing   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> screen_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># arbitrary scale</span></span>
<span id="cb1-6"></span>
<span id="cb1-7">d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(screen_time, wellbeing)</span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(d)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>  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</code></pre>
</div>
</div>
<p>A quick linear model:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(wellbeing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> screen_time, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> d)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>
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(&gt;|t|)    
(Intercept)  69.6767     0.7788   89.47   &lt;2e-16 ***
screen_time  -3.1250     0.2100  -14.88   &lt;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: &lt; 2.2e-16</code></pre>
</div>
</div>
<p>And the figure, with the code that draws it right above it in the source:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>screen_time, d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>wellbeing,</span>
<span id="cb5-2">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pch =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">19</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0077b388"</span>,</span>
<span id="cb5-3">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Screen time (hours/day)"</span>,</span>
<span id="cb5-4">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well-being score"</span>,</span>
<span id="cb5-5">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bty =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>)</span>
<span id="cb5-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abline</span>(fit, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#005c88"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lwd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div id="fig-screentime" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-screentime-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://dougaparry.com/posts/welcome/index_files/figure-html/fig-screentime-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-screentime-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Simulated association between daily screen time and a well-being score.
</figcaption>
</figure>
</div>
</div>
</div>
<p>That’s the whole idea: the analysis and the write-up are one document. To add a post, I create a new folder under <code>posts/</code>, drop an <code>index.qmd</code> inside, and write. Because of <code>freeze: true</code> in <code>posts/_metadata.yml</code>, the code only re-runs when I change the post, so rebuilding the site stays fast even as the analyses pile up.</p>


<!-- -->


 ]]></description>
  <category>R</category>
  <category>open science</category>
  <category>meta</category>
  <guid>https://dougaparry.com/posts/welcome/</guid>
  <pubDate>Thu, 09 Jul 2026 00:00:00 GMT</pubDate>
  <media:content url="https://dougaparry.com/posts/welcome/thumbnail.png" medium="image" type="image/png" height="96" width="144"/>
</item>
</channel>
</rss>
