updated intro

This commit is contained in:
Jeremy Kidwell 2023-10-12 17:08:37 +01:00
parent 3a657d6b2f
commit a7109b28a8
37 changed files with 925 additions and 388 deletions

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 2&nbsp; The 2021 UK Census</title> <title>Hacking Religion: TRS &amp; Data Science in Action - 1&nbsp; The 2021 UK Census</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -127,7 +127,7 @@ div.csl-indent {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_1.html"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_1.html"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -161,31 +161,37 @@ div.csl-indent {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link active"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -210,17 +216,17 @@ div.csl-indent {
<h2 id="toc-title">Table of contents</h2> <h2 id="toc-title">Table of contents</h2>
<ul> <ul>
<li><a href="#your-first-project-the-uk-census" id="toc-your-first-project-the-uk-census" class="nav-link active" data-scroll-target="#your-first-project-the-uk-census"><span class="header-section-number">2.1</span> Your first project: the UK Census</a></li> <li><a href="#your-first-project-the-uk-census" id="toc-your-first-project-the-uk-census" class="nav-link active" data-scroll-target="#your-first-project-the-uk-census"><span class="header-section-number">1.1</span> Your first project: the UK Census</a></li>
<li><a href="#examining-data" id="toc-examining-data" class="nav-link" data-scroll-target="#examining-data"><span class="header-section-number">2.2</span> Examining data:</a></li> <li><a href="#examining-data" id="toc-examining-data" class="nav-link" data-scroll-target="#examining-data"><span class="header-section-number">1.2</span> Examining data:</a></li>
<li><a href="#parsing-and-exploring-your-data" id="toc-parsing-and-exploring-your-data" class="nav-link" data-scroll-target="#parsing-and-exploring-your-data"><span class="header-section-number">2.3</span> Parsing and Exploring your data</a></li> <li><a href="#parsing-and-exploring-your-data" id="toc-parsing-and-exploring-your-data" class="nav-link" data-scroll-target="#parsing-and-exploring-your-data"><span class="header-section-number">1.3</span> Parsing and Exploring your data</a></li>
<li><a href="#making-your-first-data-visulation-the-humble-bar-chart" id="toc-making-your-first-data-visulation-the-humble-bar-chart" class="nav-link" data-scroll-target="#making-your-first-data-visulation-the-humble-bar-chart"><span class="header-section-number">2.4</span> Making your first data visulation: the humble bar chart</a> <li><a href="#making-your-first-data-visulation-the-humble-bar-chart" id="toc-making-your-first-data-visulation-the-humble-bar-chart" class="nav-link" data-scroll-target="#making-your-first-data-visulation-the-humble-bar-chart"><span class="header-section-number">1.4</span> Making your first data visulation: the humble bar chart</a>
<ul class="collapse"> <ul class="collapse">
<li><a href="#base-r" id="toc-base-r" class="nav-link" data-scroll-target="#base-r"><span class="header-section-number">2.4.1</span> Base R</a></li> <li><a href="#base-r" id="toc-base-r" class="nav-link" data-scroll-target="#base-r"><span class="header-section-number">1.4.1</span> Base R</a></li>
<li><a href="#ggplot" id="toc-ggplot" class="nav-link" data-scroll-target="#ggplot"><span class="header-section-number">2.4.2</span> GGPlot</a></li> <li><a href="#ggplot" id="toc-ggplot" class="nav-link" data-scroll-target="#ggplot"><span class="header-section-number">1.4.2</span> GGPlot</a></li>
</ul></li> </ul></li>
<li><a href="#is-your-chart-accurate-telling-the-truth-in-data-science" id="toc-is-your-chart-accurate-telling-the-truth-in-data-science" class="nav-link" data-scroll-target="#is-your-chart-accurate-telling-the-truth-in-data-science"><span class="header-section-number">2.5</span> Is your chart accurate? Telling the truth in data science</a></li> <li><a href="#is-your-chart-accurate-telling-the-truth-in-data-science" id="toc-is-your-chart-accurate-telling-the-truth-in-data-science" class="nav-link" data-scroll-target="#is-your-chart-accurate-telling-the-truth-in-data-science"><span class="header-section-number">1.5</span> Is your chart accurate? Telling the truth in data science</a></li>
<li><a href="#making-our-script-reproducible" id="toc-making-our-script-reproducible" class="nav-link" data-scroll-target="#making-our-script-reproducible"><span class="header-section-number">2.6</span> Making our script reproducible</a></li> <li><a href="#making-our-script-reproducible" id="toc-making-our-script-reproducible" class="nav-link" data-scroll-target="#making-our-script-reproducible"><span class="header-section-number">1.6</span> Making our script reproducible</a></li>
<li><a href="#multifactor-visualisation" id="toc-multifactor-visualisation" class="nav-link" data-scroll-target="#multifactor-visualisation"><span class="header-section-number">2.7</span> Multifactor Visualisation</a></li> <li><a href="#multifactor-visualisation" id="toc-multifactor-visualisation" class="nav-link" data-scroll-target="#multifactor-visualisation"><span class="header-section-number">1.7</span> Multifactor Visualisation</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li> <li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul> </ul>
</nav> </nav>
@ -230,7 +236,7 @@ div.csl-indent {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></h1> <h1 class="title"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></h1>
</div> </div>
@ -245,8 +251,8 @@ div.csl-indent {
</header> </header>
<section id="your-first-project-the-uk-census" class="level2 page-columns page-full" data-number="2.1"> <section id="your-first-project-the-uk-census" class="level2 page-columns page-full" data-number="1.1">
<h2 data-number="2.1" class="anchored" data-anchor-id="your-first-project-the-uk-census"><span class="header-section-number">2.1</span> Your first project: the UK Census</h2> <h2 data-number="1.1" class="anchored" data-anchor-id="your-first-project-the-uk-census"><span class="header-section-number">1.1</span> Your first project: the UK Census</h2>
<p>Lets start by importing some data into R. Because R is what is called an object-oriented programming language, well always take our information and give it a home inside a named object. There are many different kinds of objects, which you can specify, but usually R will assign a type that seems to fit best.</p> <p>Lets start by importing some data into R. Because R is what is called an object-oriented programming language, well always take our information and give it a home inside a named object. There are many different kinds of objects, which you can specify, but usually R will assign a type that seems to fit best.</p>
<div class="page-columns page-full"><p></p><div class="no-row-height column-margin column-container"><span class="">If youd like to explore this all in a bit more depth, you can find a very helpful summary in R for Data Science, chapter 8, <a href="https://r4ds.hadley.nz/data-import#reading-data-from-a-file">“data import”</a>.</span></div></div> <div class="page-columns page-full"><p></p><div class="no-row-height column-margin column-container"><span class="">If youd like to explore this all in a bit more depth, you can find a very helpful summary in R for Data Science, chapter 8, <a href="https://r4ds.hadley.nz/data-import#reading-data-from-a-file">“data import”</a>.</span></div></div>
<p>In the example below, were going to read in data from a comma separated value file (“csv”) which has rows of information on separate lines in a text file with each column separated by a comma. This is one of the standard plain text file formats. R has a function you can use to import this efficiently called “read.csv”. Each line of code in R usually starts with the object, and then follows with instructions on what were going to put inside it, where that comes from, and how to format it:</p> <p>In the example below, were going to read in data from a comma separated value file (“csv”) which has rows of information on separate lines in a text file with each column separated by a comma. This is one of the standard plain text file formats. R has a function you can use to import this efficiently called “read.csv”. Each line of code in R usually starts with the object, and then follows with instructions on what were going to put inside it, where that comes from, and how to format it:</p>
@ -272,8 +278,8 @@ div.csl-indent {
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">here</span>(<span class="st">"example_data"</span>, <span class="st">"census2021-ts030-rgn.csv"</span>)) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">here</span>(<span class="st">"example_data"</span>, <span class="st">"census2021-ts030-rgn.csv"</span>)) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div> </div>
</section> </section>
<section id="examining-data" class="level2" data-number="2.2"> <section id="examining-data" class="level2" data-number="1.2">
<h2 data-number="2.2" class="anchored" data-anchor-id="examining-data"><span class="header-section-number">2.2</span> Examining data:</h2> <h2 data-number="1.2" class="anchored" data-anchor-id="examining-data"><span class="header-section-number">1.2</span> Examining data:</h2>
<p>Whats in the table? You can take a quick look at either the top of the data frame, or the bottom using one of the following commands:</p> <p>Whats in the table? You can take a quick look at either the top of the data frame, or the bottom using one of the following commands:</p>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(uk_census_2021_religion)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(uk_census_2021_religion)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
@ -535,8 +541,8 @@ div.csl-indent {
</div> </div>
</div> </div>
</section> </section>
<section id="parsing-and-exploring-your-data" class="level2 page-columns page-full" data-number="2.3"> <section id="parsing-and-exploring-your-data" class="level2 page-columns page-full" data-number="1.3">
<h2 data-number="2.3" class="anchored" data-anchor-id="parsing-and-exploring-your-data"><span class="header-section-number">2.3</span> Parsing and Exploring your data</h2> <h2 data-number="1.3" class="anchored" data-anchor-id="parsing-and-exploring-your-data"><span class="header-section-number">1.3</span> Parsing and Exploring your data</h2>
<p>The first thing youre going to want to do is to take a smaller subset of a large data set, either by filtering out certain columns or rows. Now lets say we want to just work with the data from the West Midlands, and wed like to omit some of the columns. We can choose a specific range of columns using <code>select</code>, like this:</p> <p>The first thing youre going to want to do is to take a smaller subset of a large data set, either by filtering out certain columns or rows. Now lets say we want to just work with the data from the West Midlands, and wed like to omit some of the columns. We can choose a specific range of columns using <code>select</code>, like this:</p>
<p>You can use the <code>filter</code> command to do this. To give an example, <code>filter</code> can pick a single row in the following way:</p> <p>You can use the <code>filter</code> command to do this. To give an example, <code>filter</code> can pick a single row in the following way:</p>
<div class="cell"> <div class="cell">
@ -546,16 +552,16 @@ div.csl-indent {
<div class="page-columns page-full"><p></p><div class="no-row-height column-margin column-container"><span class="">Some readers will want to pause here and check out Hadley Wickhams “R For Data Science” book, in the section, <a href="https://r4ds.hadley.nz/data-visualize#introduction">“Data visualisation”</a> to get a fuller explanation of how to explore your data.</span></div></div> <div class="page-columns page-full"><p></p><div class="no-row-height column-margin column-container"><span class="">Some readers will want to pause here and check out Hadley Wickhams “R For Data Science” book, in the section, <a href="https://r4ds.hadley.nz/data-visualize#introduction">“Data visualisation”</a> to get a fuller explanation of how to explore your data.</span></div></div>
<p>In keeping with my goal to demonstrate data science through examples, were going to move on to producing some snappy looking charts for this data.</p> <p>In keeping with my goal to demonstrate data science through examples, were going to move on to producing some snappy looking charts for this data.</p>
</section> </section>
<section id="making-your-first-data-visulation-the-humble-bar-chart" class="level2 page-columns page-full" data-number="2.4"> <section id="making-your-first-data-visulation-the-humble-bar-chart" class="level2 page-columns page-full" data-number="1.4">
<h2 data-number="2.4" class="anchored" data-anchor-id="making-your-first-data-visulation-the-humble-bar-chart"><span class="header-section-number">2.4</span> Making your first data visulation: the humble bar chart</h2> <h2 data-number="1.4" class="anchored" data-anchor-id="making-your-first-data-visulation-the-humble-bar-chart"><span class="header-section-number">1.4</span> Making your first data visulation: the humble bar chart</h2>
<p>Weve got a nice lean set of data, so now its time to visualise this. Well start by making a pie chart:</p> <p>Weve got a nice lean set of data, so now its time to visualise this. Well start by making a pie chart:</p>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion_wmids <span class="ot">&lt;-</span> uk_census_2021_religion_wmids <span class="sc">%&gt;%</span> <span class="fu">select</span>(no_religion<span class="sc">:</span>no_response)</span> <div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion_wmids <span class="ot">&lt;-</span> uk_census_2021_religion_wmids <span class="sc">%&gt;%</span> <span class="fu">select</span>(no_religion<span class="sc">:</span>no_response)</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion_wmids <span class="ot">&lt;-</span> <span class="fu">gather</span>(uk_census_2021_religion_wmids)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>uk_census_2021_religion_wmids <span class="ot">&lt;-</span> <span class="fu">gather</span>(uk_census_2021_religion_wmids)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div> </div>
<p>There are two basic ways to do visualisations in R. You can work with basic functions in R, often called “base R” or you can work with an alternative library called ggplot:</p> <p>There are two basic ways to do visualisations in R. You can work with basic functions in R, often called “base R” or you can work with an alternative library called ggplot:</p>
<section id="base-r" class="level3" data-number="2.4.1"> <section id="base-r" class="level3" data-number="1.4.1">
<h3 data-number="2.4.1" class="anchored" data-anchor-id="base-r"><span class="header-section-number">2.4.1</span> Base R</h3> <h3 data-number="1.4.1" class="anchored" data-anchor-id="base-r"><span class="header-section-number">1.4.1</span> Base R</h3>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>df <span class="ot">&lt;-</span> uk_census_2021_religion_wmids[<span class="fu">order</span>(uk_census_2021_religion_wmids<span class="sc">$</span>value,<span class="at">decreasing =</span> <span class="cn">TRUE</span>),]</span> <div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>df <span class="ot">&lt;-</span> uk_census_2021_religion_wmids[<span class="fu">order</span>(uk_census_2021_religion_wmids<span class="sc">$</span>value,<span class="at">decreasing =</span> <span class="cn">TRUE</span>),]</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="fu">barplot</span>(<span class="at">height=</span>df<span class="sc">$</span>value, <span class="at">names=</span>df<span class="sc">$</span>key)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="fu">barplot</span>(<span class="at">height=</span>df<span class="sc">$</span>value, <span class="at">names=</span>df<span class="sc">$</span>key)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
@ -564,8 +570,8 @@ div.csl-indent {
</div> </div>
</div> </div>
</section> </section>
<section id="ggplot" class="level3 page-columns page-full" data-number="2.4.2"> <section id="ggplot" class="level3 page-columns page-full" data-number="1.4.2">
<h3 data-number="2.4.2" class="anchored" data-anchor-id="ggplot"><span class="header-section-number">2.4.2</span> GGPlot</h3> <h3 data-number="1.4.2" class="anchored" data-anchor-id="ggplot"><span class="header-section-number">1.4.2</span> GGPlot</h3>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="annotated-cell-9"><pre class="sourceCode r code-annotation-code code-with-copy"><code class="sourceCode r"><span id="annotated-cell-9-1"><a href="#annotated-cell-9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(uk_census_2021_religion_wmids, <span class="fu">aes</span>(<span class="at">x =</span> key, <span class="at">y =</span> value)) <span class="sc">+</span></span> <div class="sourceCode cell-code" id="annotated-cell-9"><pre class="sourceCode r code-annotation-code code-with-copy"><code class="sourceCode r"><span id="annotated-cell-9-1"><a href="#annotated-cell-9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(uk_census_2021_religion_wmids, <span class="fu">aes</span>(<span class="at">x =</span> key, <span class="at">y =</span> value)) <span class="sc">+</span></span>
<span id="annotated-cell-9-2"><a href="#annotated-cell-9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">stat =</span> <span class="st">"identity"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="annotated-cell-9-2"><a href="#annotated-cell-9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">stat =</span> <span class="st">"identity"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
@ -573,7 +579,7 @@ div.csl-indent {
<dl class="code-annotation-container-grid"> <dl class="code-annotation-container-grid">
<dt data-target-cell="annotated-cell-10" data-target-annotation="2">2</dt> <dt data-target-cell="annotated-cell-10" data-target-annotation="2">2</dt>
<dd> <dd>
<span data-code-cell="annotated-cell-10" data-code-lines="1" data-code-annotation="2">Well re-order the column by size.</span> <span data-code-cell="annotated-cell-10" data-code-annotation="2" data-code-lines="1">Well re-order the column by size.</span>
</dd> </dd>
</dl> </dl>
</div> </div>
@ -596,19 +602,19 @@ div.csl-indent {
<dl class="code-annotation-container-grid"> <dl class="code-annotation-container-grid">
<dt data-target-cell="annotated-cell-11" data-target-annotation="1">1</dt> <dt data-target-cell="annotated-cell-11" data-target-annotation="1">1</dt>
<dd> <dd>
<span data-code-cell="annotated-cell-11" data-code-lines="1" data-code-annotation="1">First, remove the column with region names and the totals for the regions as we want just integer data.</span> <span data-code-cell="annotated-cell-11" data-code-annotation="1" data-code-lines="1">First, remove the column with region names and the totals for the regions as we want just integer data.</span>
</dd> </dd>
<dt data-target-cell="annotated-cell-11" data-target-annotation="2">2</dt> <dt data-target-cell="annotated-cell-11" data-target-annotation="2">2</dt>
<dd> <dd>
<span data-code-cell="annotated-cell-11" data-code-lines="3" data-code-annotation="2">Second calculate the totals. In this example we use the tidyverse library <code>dplyr()</code>, but you can also do this using base R with <code>colsums()</code> like this: <code>uk_census_2021_religion_totals &lt;- colSums(uk_census_2021_religion_totals, na.rm = TRUE)</code>. The downside with base R is that youll also need to convert the result into a dataframe for <code>ggplot</code> like this: <code>uk_census_2021_religion_totals &lt;- as.data.frame(uk_census_2021_religion_totals)</code></span> <span data-code-cell="annotated-cell-11" data-code-annotation="2" data-code-lines="3">Second calculate the totals. In this example we use the tidyverse library <code>dplyr()</code>, but you can also do this using base R with <code>colsums()</code> like this: <code>uk_census_2021_religion_totals &lt;- colSums(uk_census_2021_religion_totals, na.rm = TRUE)</code>. The downside with base R is that youll also need to convert the result into a dataframe for <code>ggplot</code> like this: <code>uk_census_2021_religion_totals &lt;- as.data.frame(uk_census_2021_religion_totals)</code></span>
</dd> </dd>
<dt data-target-cell="annotated-cell-11" data-target-annotation="3">3</dt> <dt data-target-cell="annotated-cell-11" data-target-annotation="3">3</dt>
<dd> <dd>
<span data-code-cell="annotated-cell-11" data-code-lines="4" data-code-annotation="3">In order to visualise this data using ggplot, we need to shift this data from wide to long format. This is a quick job using gather()</span> <span data-code-cell="annotated-cell-11" data-code-annotation="3" data-code-lines="4">In order to visualise this data using ggplot, we need to shift this data from wide to long format. This is a quick job using gather()</span>
</dd> </dd>
<dt data-target-cell="annotated-cell-11" data-target-annotation="4">4</dt> <dt data-target-cell="annotated-cell-11" data-target-annotation="4">4</dt>
<dd> <dd>
<span data-code-cell="annotated-cell-11" data-code-lines="5" data-code-annotation="4">Now plot it out and have a look!</span> <span data-code-cell="annotated-cell-11" data-code-annotation="4" data-code-lines="5">Now plot it out and have a look!</span>
</dd> </dd>
</dl> </dl>
</div> </div>
@ -674,8 +680,8 @@ div.csl-indent {
</div> </div>
</section> </section>
</section> </section>
<section id="is-your-chart-accurate-telling-the-truth-in-data-science" class="level2" data-number="2.5"> <section id="is-your-chart-accurate-telling-the-truth-in-data-science" class="level2" data-number="1.5">
<h2 data-number="2.5" class="anchored" data-anchor-id="is-your-chart-accurate-telling-the-truth-in-data-science"><span class="header-section-number">2.5</span> Is your chart accurate? Telling the truth in data science</h2> <h2 data-number="1.5" class="anchored" data-anchor-id="is-your-chart-accurate-telling-the-truth-in-data-science"><span class="header-section-number">1.5</span> Is your chart accurate? Telling the truth in data science</h2>
<p>There is some technical work yet to be done fine-tuning the visualisation of our chart here. But Id like to pause for a moment and consider an ethical question. Is the title of this chart truthful and accurate? On one hand, it is a straight-forward reference to the nature of the question asked on the 2021 census survey instrument. However, as you will see in the next chapter, large data sets from the same year which asked a fairly similar question yield different results. Part of this could be attributed to the amount of non-respose to this specific question which, in the 2021 census is between 5-6% across many demographics. Its possible (though perhaps unlikely) that all those non-responses were Sikh respondents who felt uncomfortable identifying themselves on such a survey. If even half of the non-responses were of this nature, this would dramatically shift the results especially in comparison to other minority groups. So there is some work for us to do here in representing non-response as a category on the census.</p> <p>There is some technical work yet to be done fine-tuning the visualisation of our chart here. But Id like to pause for a moment and consider an ethical question. Is the title of this chart truthful and accurate? On one hand, it is a straight-forward reference to the nature of the question asked on the 2021 census survey instrument. However, as you will see in the next chapter, large data sets from the same year which asked a fairly similar question yield different results. Part of this could be attributed to the amount of non-respose to this specific question which, in the 2021 census is between 5-6% across many demographics. Its possible (though perhaps unlikely) that all those non-responses were Sikh respondents who felt uncomfortable identifying themselves on such a survey. If even half of the non-responses were of this nature, this would dramatically shift the results especially in comparison to other minority groups. So there is some work for us to do here in representing non-response as a category on the census.</p>
<p>Its equally possible that someone might feel uncertain when answering, but nonetheless land on a particular decision marking “Christian” when they wondered if they should instead tick “no religion. Some surveys attempt to capture uncertainty in this way, asking respondents to mark how confident they are about their answers, but the census hasnt capture this so we simply dont know. If a large portion of respondents in the”Christian” category were hovering between this and another response, again, they might shift their answers when responding on a different day, perhaps having just had a conversation with a friend which shifted their thinking. Even the inertia of survey design can have an effect on this, so responding to other questions in a particular way, thinking about ethnic identity, for example, can prime a person to think about their religious identity in a different or more focussed way, altering their response to the question. For this reason, some survey instruments randomise the order of questions. This hasnt been done on the census (which would have been quite hard work given that most of the instruments were printed hard copies!), so again, we cant really be sure if those answers given are stable.</p> <p>Its equally possible that someone might feel uncertain when answering, but nonetheless land on a particular decision marking “Christian” when they wondered if they should instead tick “no religion. Some surveys attempt to capture uncertainty in this way, asking respondents to mark how confident they are about their answers, but the census hasnt capture this so we simply dont know. If a large portion of respondents in the”Christian” category were hovering between this and another response, again, they might shift their answers when responding on a different day, perhaps having just had a conversation with a friend which shifted their thinking. Even the inertia of survey design can have an effect on this, so responding to other questions in a particular way, thinking about ethnic identity, for example, can prime a person to think about their religious identity in a different or more focussed way, altering their response to the question. For this reason, some survey instruments randomise the order of questions. This hasnt been done on the census (which would have been quite hard work given that most of the instruments were printed hard copies!), so again, we cant really be sure if those answers given are stable.</p>
<p>Finally, researchers have also found that when people are asked to mark their religious affiliation, sometimes they can prefer to mark more than one answer. A person might consider themselves to be “Muslim” but also “Spiritual but not religious” preferring the combination of those identities. It is also the case that respondents can identify with more unexpected hybrid religious identities, such as “Christian” and “Hindu”. The census only allows respondents to tick a single box for the religion category. It is worth noting that, in contrast, the responses for ethnicity allow for combinations. Given that this is the case, its impossible to know which way a person went at the fork in the road as they were forced to choose just one half of this kind of hybrid identity. Finally, it is interesting to wonder exactly what it means for a person when they tick a box like this. Is it because they attend synagogue on a weekly basis? Some persons would consider weekly attendance at workship a prerequisite for membership in a group, but others would not. Indeed we can infer from surveys and research which aims to track rates of participation in weekly worship that many people who tick boxes for particular religious identities on the census have never attended a worship service at all.</p> <p>Finally, researchers have also found that when people are asked to mark their religious affiliation, sometimes they can prefer to mark more than one answer. A person might consider themselves to be “Muslim” but also “Spiritual but not religious” preferring the combination of those identities. It is also the case that respondents can identify with more unexpected hybrid religious identities, such as “Christian” and “Hindu”. The census only allows respondents to tick a single box for the religion category. It is worth noting that, in contrast, the responses for ethnicity allow for combinations. Given that this is the case, its impossible to know which way a person went at the fork in the road as they were forced to choose just one half of this kind of hybrid identity. Finally, it is interesting to wonder exactly what it means for a person when they tick a box like this. Is it because they attend synagogue on a weekly basis? Some persons would consider weekly attendance at workship a prerequisite for membership in a group, but others would not. Indeed we can infer from surveys and research which aims to track rates of participation in weekly worship that many people who tick boxes for particular religious identities on the census have never attended a worship service at all.</p>
@ -689,12 +695,12 @@ div.csl-indent {
<p>Change orientation of X axis labels + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</p> <p>Change orientation of X axis labels + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))</p>
<p>Relabel fields Simplify y-axis labels Add percentage text to bars (or maybe save for next chapter?)</p> <p>Relabel fields Simplify y-axis labels Add percentage text to bars (or maybe save for next chapter?)</p>
</section> </section>
<section id="making-our-script-reproducible" class="level2" data-number="2.6"> <section id="making-our-script-reproducible" class="level2" data-number="1.6">
<h2 data-number="2.6" class="anchored" data-anchor-id="making-our-script-reproducible"><span class="header-section-number">2.6</span> Making our script reproducible</h2> <h2 data-number="1.6" class="anchored" data-anchor-id="making-our-script-reproducible"><span class="header-section-number">1.6</span> Making our script reproducible</h2>
<p>Lets take a moment to review our hacker code. Ive just spent some time addressing how we can be truthful in our data science work. We havent done much yet to talk abour reproducibility.</p> <p>Lets take a moment to review our hacker code. Ive just spent some time addressing how we can be truthful in our data science work. We havent done much yet to talk abour reproducibility.</p>
</section> </section>
<section id="multifactor-visualisation" class="level2" data-number="2.7"> <section id="multifactor-visualisation" class="level2" data-number="1.7">
<h2 data-number="2.7" class="anchored" data-anchor-id="multifactor-visualisation"><span class="header-section-number">2.7</span> Multifactor Visualisation</h2> <h2 data-number="1.7" class="anchored" data-anchor-id="multifactor-visualisation"><span class="header-section-number">1.7</span> Multifactor Visualisation</h2>
<p>One element of R data analysis that can get really interesting is working with multiple variables. Above weve looked at the breakdown of religious affiliation across the whole of England and Wales (Scotland operates an independent census), and by placing this data alongside a specific region, weve already made a basic entry into working with multiple variables but this can get much more interesting. Adding an additional quantative variable (also known as bivariate data) into the mix, however can also generate a lot more information and we have to think about visualising it in different ways which can still communicate with visual clarity in spite of the additional visual noise which is inevitable with enhanced complexity. Lets have a look at the way that religion in England and Wales breaks down by ethnicity.</p> <p>One element of R data analysis that can get really interesting is working with multiple variables. Above weve looked at the breakdown of religious affiliation across the whole of England and Wales (Scotland operates an independent census), and by placing this data alongside a specific region, weve already made a basic entry into working with multiple variables but this can get much more interesting. Adding an additional quantative variable (also known as bivariate data) into the mix, however can also generate a lot more information and we have to think about visualising it in different ways which can still communicate with visual clarity in spite of the additional visual noise which is inevitable with enhanced complexity. Lets have a look at the way that religion in England and Wales breaks down by ethnicity.</p>
<div class="callout callout-style-default callout-tip callout-titled"> <div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center"> <div class="callout-header d-flex align-content-center">
@ -1117,12 +1123,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
<nav class="page-navigation"> <nav class="page-navigation">
<div class="nav-page nav-page-previous"> <div class="nav-page nav-page-previous">
<a href="./intro.html" class="pagination-link"> <a href="./intro.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span> <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Introduction: Hacking Religion</span>
</a> </a>
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./chapter_2.html" class="pagination-link"> <a href="./chapter_2.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 3&nbsp; Survey Data: Spotlight Project</title> <title>Hacking Religion: TRS &amp; Data Science in Action - 2&nbsp; Survey Data: Spotlight Project</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -129,7 +129,7 @@ div.csl-indent {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_2.html"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_2.html"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -163,31 +163,37 @@ div.csl-indent {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link active"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -212,33 +218,33 @@ div.csl-indent {
<h2 id="toc-title">Table of contents</h2> <h2 id="toc-title">Table of contents</h2>
<ul> <ul>
<li><a href="#loading-in-some-data" id="toc-loading-in-some-data" class="nav-link active" data-scroll-target="#loading-in-some-data"><span class="header-section-number">4</span> Loading in some data</a></li> <li><a href="#loading-in-some-data" id="toc-loading-in-some-data" class="nav-link active" data-scroll-target="#loading-in-some-data"><span class="header-section-number">3</span> Loading in some data</a></li>
<li><a href="#how-can-you-ask-about-religion" id="toc-how-can-you-ask-about-religion" class="nav-link" data-scroll-target="#how-can-you-ask-about-religion"><span class="header-section-number">5</span> How can you ask about religion?</a></li> <li><a href="#how-can-you-ask-about-religion" id="toc-how-can-you-ask-about-religion" class="nav-link" data-scroll-target="#how-can-you-ask-about-religion"><span class="header-section-number">4</span> How can you ask about religion?</a></li>
<li><a href="#q56-follow-ups" id="toc-q56-follow-ups" class="nav-link" data-scroll-target="#q56-follow-ups"><span class="header-section-number">6</span> Q56 follow-ups</a></li> <li><a href="#q56-follow-ups" id="toc-q56-follow-ups" class="nav-link" data-scroll-target="#q56-follow-ups"><span class="header-section-number">5</span> Q56 follow-ups</a></li>
<li><a href="#religious-affiliation-c---muslim-denomination-subquestion" id="toc-religious-affiliation-c---muslim-denomination-subquestion" class="nav-link" data-scroll-target="#religious-affiliation-c---muslim-denomination-subquestion"><span class="header-section-number">7</span> Religious Affiliation c - Muslim Denomination Subquestion</a></li> <li><a href="#religious-affiliation-c---muslim-denomination-subquestion" id="toc-religious-affiliation-c---muslim-denomination-subquestion" class="nav-link" data-scroll-target="#religious-affiliation-c---muslim-denomination-subquestion"><span class="header-section-number">6</span> Religious Affiliation c - Muslim Denomination Subquestion</a></li>
<li><a href="#q57" id="toc-q57" class="nav-link" data-scroll-target="#q57"><span class="header-section-number">8</span> Q57</a></li> <li><a href="#q57" id="toc-q57" class="nav-link" data-scroll-target="#q57"><span class="header-section-number">7</span> Q57</a></li>
<li><a href="#religiosity" id="toc-religiosity" class="nav-link" data-scroll-target="#religiosity"><span class="header-section-number">9</span> Religiosity</a></li> <li><a href="#religiosity" id="toc-religiosity" class="nav-link" data-scroll-target="#religiosity"><span class="header-section-number">8</span> Religiosity</a></li>
<li><a href="#q58" id="toc-q58" class="nav-link" data-scroll-target="#q58"><span class="header-section-number">10</span> Q58</a></li> <li><a href="#q58" id="toc-q58" class="nav-link" data-scroll-target="#q58"><span class="header-section-number">9</span> Q58</a></li>
<li><a href="#faceted-plot-working-with-3x3-grid" id="toc-faceted-plot-working-with-3x3-grid" class="nav-link" data-scroll-target="#faceted-plot-working-with-3x3-grid"><span class="header-section-number">11</span> Faceted plot working with 3x3 grid</a></li> <li><a href="#faceted-plot-working-with-3x3-grid" id="toc-faceted-plot-working-with-3x3-grid" class="nav-link" data-scroll-target="#faceted-plot-working-with-3x3-grid"><span class="header-section-number">10</span> Faceted plot working with 3x3 grid</a></li>
<li><a href="#q59" id="toc-q59" class="nav-link" data-scroll-target="#q59"><span class="header-section-number">12</span> Q59</a></li> <li><a href="#q59" id="toc-q59" class="nav-link" data-scroll-target="#q59"><span class="header-section-number">11</span> Q59</a></li>
<li><a href="#faceted-plot-working-with-3x3-grid-1" id="toc-faceted-plot-working-with-3x3-grid-1" class="nav-link" data-scroll-target="#faceted-plot-working-with-3x3-grid-1"><span class="header-section-number">13</span> Faceted plot working with 3x3 grid</a></li> <li><a href="#faceted-plot-working-with-3x3-grid-1" id="toc-faceted-plot-working-with-3x3-grid-1" class="nav-link" data-scroll-target="#faceted-plot-working-with-3x3-grid-1"><span class="header-section-number">12</span> Faceted plot working with 3x3 grid</a></li>
<li><a href="#comparing-with-attitudes-surrounding-climate-change" id="toc-comparing-with-attitudes-surrounding-climate-change" class="nav-link" data-scroll-target="#comparing-with-attitudes-surrounding-climate-change"><span class="header-section-number">14</span> Comparing with attitudes surrounding climate change</a></li> <li><a href="#comparing-with-attitudes-surrounding-climate-change" id="toc-comparing-with-attitudes-surrounding-climate-change" class="nav-link" data-scroll-target="#comparing-with-attitudes-surrounding-climate-change"><span class="header-section-number">13</span> Comparing with attitudes surrounding climate change</a></li>
<li><a href="#q6" id="toc-q6" class="nav-link" data-scroll-target="#q6"><span class="header-section-number">15</span> Q6</a></li> <li><a href="#q6" id="toc-q6" class="nav-link" data-scroll-target="#q6"><span class="header-section-number">14</span> Q6</a></li>
<li><a href="#subsetting" id="toc-subsetting" class="nav-link" data-scroll-target="#subsetting"><span class="header-section-number">16</span> Subsetting</a> <li><a href="#subsetting" id="toc-subsetting" class="nav-link" data-scroll-target="#subsetting"><span class="header-section-number">15</span> Subsetting</a>
<ul class="collapse"> <ul class="collapse">
<li><a href="#q57-subsetting-based-on-religiosity" id="toc-q57-subsetting-based-on-religiosity" class="nav-link" data-scroll-target="#q57-subsetting-based-on-religiosity"><span class="header-section-number">16.1</span> Q57 subsetting based on Religiosity ————————————————————–</a></li> <li><a href="#q57-subsetting-based-on-religiosity" id="toc-q57-subsetting-based-on-religiosity" class="nav-link" data-scroll-target="#q57-subsetting-based-on-religiosity"><span class="header-section-number">15.1</span> Q57 subsetting based on Religiosity ————————————————————–</a></li>
<li><a href="#subsetting-based-on-spirituality" id="toc-subsetting-based-on-spirituality" class="nav-link" data-scroll-target="#subsetting-based-on-spirituality"><span class="header-section-number">16.2</span> Subsetting based on Spirituality ————————————————————–</a> <li><a href="#subsetting-based-on-spirituality" id="toc-subsetting-based-on-spirituality" class="nav-link" data-scroll-target="#subsetting-based-on-spirituality"><span class="header-section-number">15.2</span> Subsetting based on Spirituality ————————————————————–</a>
<ul class="collapse"> <ul class="collapse">
<li><a href="#nature-relatedness" id="toc-nature-relatedness" class="nav-link" data-scroll-target="#nature-relatedness"><span class="header-section-number">16.2.1</span> Nature relatedness ————————————————————–</a></li> <li><a href="#nature-relatedness" id="toc-nature-relatedness" class="nav-link" data-scroll-target="#nature-relatedness"><span class="header-section-number">15.2.1</span> Nature relatedness ————————————————————–</a></li>
</ul></li> </ul></li>
</ul></li> </ul></li>
<li><a href="#calculate-overall-mean-nature-relatedness-score-based-on-six-questions" id="toc-calculate-overall-mean-nature-relatedness-score-based-on-six-questions" class="nav-link" data-scroll-target="#calculate-overall-mean-nature-relatedness-score-based-on-six-questions"><span class="header-section-number">17</span> Calculate overall mean nature-relatedness score based on six questions:</a></li> <li><a href="#calculate-overall-mean-nature-relatedness-score-based-on-six-questions" id="toc-calculate-overall-mean-nature-relatedness-score-based-on-six-questions" class="nav-link" data-scroll-target="#calculate-overall-mean-nature-relatedness-score-based-on-six-questions"><span class="header-section-number">16</span> Calculate overall mean nature-relatedness score based on six questions:</a></li>
<li><a href="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" id="toc-create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" class="nav-link" data-scroll-target="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation"><span class="header-section-number">18</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</a> <li><a href="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" id="toc-create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" class="nav-link" data-scroll-target="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation"><span class="header-section-number">17</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</a>
<ul class="collapse"> <ul class="collapse">
<li><a href="#spirituality-scale" id="toc-spirituality-scale" class="nav-link" data-scroll-target="#spirituality-scale"><span class="header-section-number">18.0.1</span> Spirituality scale ————————————————————–</a></li> <li><a href="#spirituality-scale" id="toc-spirituality-scale" class="nav-link" data-scroll-target="#spirituality-scale"><span class="header-section-number">17.0.1</span> Spirituality scale ————————————————————–</a></li>
</ul></li> </ul></li>
<li><a href="#calculate-overall-mean-spirituality-score-based-on-six-questions" id="toc-calculate-overall-mean-spirituality-score-based-on-six-questions" class="nav-link" data-scroll-target="#calculate-overall-mean-spirituality-score-based-on-six-questions"><span class="header-section-number">19</span> Calculate overall mean spirituality score based on six questions:</a></li> <li><a href="#calculate-overall-mean-spirituality-score-based-on-six-questions" id="toc-calculate-overall-mean-spirituality-score-based-on-six-questions" class="nav-link" data-scroll-target="#calculate-overall-mean-spirituality-score-based-on-six-questions"><span class="header-section-number">18</span> Calculate overall mean spirituality score based on six questions:</a></li>
<li><a href="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" id="toc-create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" class="nav-link" data-scroll-target="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1"><span class="header-section-number">20</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</a></li> <li><a href="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" id="toc-create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" class="nav-link" data-scroll-target="#create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1"><span class="header-section-number">19</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li> <li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul> </ul>
</nav> </nav>
@ -248,7 +254,7 @@ div.csl-indent {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></h1> <h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></h1>
</div> </div>
@ -267,8 +273,8 @@ div.csl-indent {
<p>For this chapter, Im going to walk you through a data set that a colleague (Charles Ogunbode) and I collected in 2021. Another problem with smaller, more selective samples is that researchers can often undersample minoritised ethnic groups. This is particularly the case with climate change research. Until the time we conducted this research, there had not been a single study investigating the specific experiences of people of colour in relation to climate change in the UK. Past researchers had been content to work with large samples, and assumed that if they had done 1000 surveys and 50 of these were completed by people of colour, they could “tick” the box. But 5% is actually well below levels of representation in the UK generally, and even more sharply the case for specific communities. And if we bear in mind that non-white respondents are (of course!) a highly heterogenous group, were even more behind in terms of collecting data that can improve our knowledge. Up until recently researchers just havent been paying close enough attention to catch the significant neglect of the empirical field that this represents.</p> <p>For this chapter, Im going to walk you through a data set that a colleague (Charles Ogunbode) and I collected in 2021. Another problem with smaller, more selective samples is that researchers can often undersample minoritised ethnic groups. This is particularly the case with climate change research. Until the time we conducted this research, there had not been a single study investigating the specific experiences of people of colour in relation to climate change in the UK. Past researchers had been content to work with large samples, and assumed that if they had done 1000 surveys and 50 of these were completed by people of colour, they could “tick” the box. But 5% is actually well below levels of representation in the UK generally, and even more sharply the case for specific communities. And if we bear in mind that non-white respondents are (of course!) a highly heterogenous group, were even more behind in terms of collecting data that can improve our knowledge. Up until recently researchers just havent been paying close enough attention to catch the significant neglect of the empirical field that this represents.</p>
<p>While Ive framed my comments above in terms of climate change research, it is also the case that, especially in diverse societies like the USA, Canada, the UK etc., paying attention to non-majority groups and people and communities of colour automatically draws in a strongly religious sample. This is highlighted in one recent study done in the UK, the “<a href="https://www.cam.ac.uk/stories/black-british-voices-report">Black British Voices Report</a>” in which the researchers observed that “84% of respondents described themselves as religious and/or spiritual”. My comments above in terms of controlling for other factors remains important here - these same researchers also note that “despire their significant important to the lives of Black Britons, only 7% of survey respondents reported that their religion was more defining of their identity than their race”.</p> <p>While Ive framed my comments above in terms of climate change research, it is also the case that, especially in diverse societies like the USA, Canada, the UK etc., paying attention to non-majority groups and people and communities of colour automatically draws in a strongly religious sample. This is highlighted in one recent study done in the UK, the “<a href="https://www.cam.ac.uk/stories/black-british-voices-report">Black British Voices Report</a>” in which the researchers observed that “84% of respondents described themselves as religious and/or spiritual”. My comments above in terms of controlling for other factors remains important here - these same researchers also note that “despire their significant important to the lives of Black Britons, only 7% of survey respondents reported that their religion was more defining of their identity than their race”.</p>
<p>Weve decided to open up access to our data and Im highlighting it in this book because its a unique opportunitiy to explore a dataset that emphasises diversity from the start, and by extension, provides some really interesting ways to use data science techniques to explore religion in the UK.</p> <p>Weve decided to open up access to our data and Im highlighting it in this book because its a unique opportunitiy to explore a dataset that emphasises diversity from the start, and by extension, provides some really interesting ways to use data science techniques to explore religion in the UK.</p>
<section id="loading-in-some-data" class="level1" data-number="4"> <section id="loading-in-some-data" class="level1" data-number="3">
<h1 data-number="4"><span class="header-section-number">4</span> Loading in some data</h1> <h1 data-number="3"><span class="header-section-number">3</span> Loading in some data</h1>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># R Setup -----------------------------------------------------------------</span></span> <div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># R Setup -----------------------------------------------------------------</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">setwd</span>(<span class="st">"/Users/kidwellj/gits/hacking_religion_textbook/hacking_religion"</span>)</span> <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">setwd</span>(<span class="st">"/Users/kidwellj/gits/hacking_religion_textbook/hacking_religion"</span>)</span>
@ -284,8 +290,8 @@ div.csl-indent {
</div> </div>
<p>The first thing to note here is that weve drawn in a different type of data file, this time from an <code>.sav</code> file, usully produced by the statistics software package SPSS. This uses a different R Library (I use <code>haven</code> for this). The upside is that in some cases where you have survey data with both a code and a value like “1” is eqivalent to “very much agree” this will preserve both in the R dataframe that is created. Now that youve loaded in data, you have a new R dataframe called “climate_experience_data” with a lot of columns with just under 1000 survey responses.</p> <p>The first thing to note here is that weve drawn in a different type of data file, this time from an <code>.sav</code> file, usully produced by the statistics software package SPSS. This uses a different R Library (I use <code>haven</code> for this). The upside is that in some cases where you have survey data with both a code and a value like “1” is eqivalent to “very much agree” this will preserve both in the R dataframe that is created. Now that youve loaded in data, you have a new R dataframe called “climate_experience_data” with a lot of columns with just under 1000 survey responses.</p>
</section> </section>
<section id="how-can-you-ask-about-religion" class="level1" data-number="5"> <section id="how-can-you-ask-about-religion" class="level1" data-number="4">
<h1 data-number="5"><span class="header-section-number">5</span> How can you ask about religion?</h1> <h1 data-number="4"><span class="header-section-number">4</span> How can you ask about religion?</h1>
<p>One of the challenges we faced when running this study is how to gather responsible data from surveys regarding religious identity. Well dive into this in depth as we do analysis and look at some of the agreements and conflicts in terms of respondent attribution. Just to set the stage, we used the following kinds of question to ask about religion and spirituality:</p> <p>One of the challenges we faced when running this study is how to gather responsible data from surveys regarding religious identity. Well dive into this in depth as we do analysis and look at some of the agreements and conflicts in terms of respondent attribution. Just to set the stage, we used the following kinds of question to ask about religion and spirituality:</p>
<ol type="1"> <ol type="1">
<li>Question 56 asks respondents simply, “What is your religion?” and then provides a range of possible answers. We included follow-up questions regarding denomination for respondents who indicated they were “Christian” or “Muslim”. For respondents who ticked “Christian” we asked, “What is your denomination?” nad for respondents who ticked “Muslim” we asked “Which of the following would you identify with?” and then left a range of possible options which could be ticked such as “Sunni,” “Shia,” “Sufi” etc.</li> <li>Question 56 asks respondents simply, “What is your religion?” and then provides a range of possible answers. We included follow-up questions regarding denomination for respondents who indicated they were “Christian” or “Muslim”. For respondents who ticked “Christian” we asked, “What is your denomination?” nad for respondents who ticked “Muslim” we asked “Which of the following would you identify with?” and then left a range of possible options which could be ticked such as “Sunni,” “Shia,” “Sufi” etc.</li>
@ -339,15 +345,15 @@ So <em>whos</em> religious?
<dl class="code-annotation-container-grid"> <dl class="code-annotation-container-grid">
<dt data-target-cell="annotated-cell-4" data-target-annotation="1">1</dt> <dt data-target-cell="annotated-cell-4" data-target-annotation="1">1</dt>
<dd> <dd>
<span data-code-annotation="1" data-code-cell="annotated-cell-4" data-code-lines="2">First we generate new a dataframe with sums per category and</span> <span data-code-annotation="1" data-code-lines="2" data-code-cell="annotated-cell-4">First we generate new a dataframe with sums per category and</span>
</dd> </dd>
<dt data-target-cell="annotated-cell-4" data-target-annotation="2">2</dt> <dt data-target-cell="annotated-cell-4" data-target-annotation="2">2</dt>
<dd> <dd>
<span data-code-annotation="2" data-code-cell="annotated-cell-4" data-code-lines="3">…sort in descending order</span> <span data-code-annotation="2" data-code-lines="3" data-code-cell="annotated-cell-4">…sort in descending order</span>
</dd> </dd>
<dt data-target-cell="annotated-cell-4" data-target-annotation="3">3</dt> <dt data-target-cell="annotated-cell-4" data-target-annotation="3">3</dt>
<dd> <dd>
<span data-code-annotation="3" data-code-cell="annotated-cell-4" data-code-lines="5">Then we add new column with percentages based on the sums youve just generated</span> <span data-code-annotation="3" data-code-lines="5" data-code-cell="annotated-cell-4">Then we add new column with percentages based on the sums youve just generated</span>
</dd> </dd>
</dl> </dl>
</div> </div>
@ -399,79 +405,79 @@ So <em>whos</em> religious?
</div> </div>
<p>Use mutate to put “prefer not to say” at the bottom # Info here: https://r4ds.had.co.nz/factors.html#modifying-factor-levels</p> <p>Use mutate to put “prefer not to say” at the bottom # Info here: https://r4ds.had.co.nz/factors.html#modifying-factor-levels</p>
</section> </section>
<section id="q56-follow-ups" class="level1" data-number="6"> <section id="q56-follow-ups" class="level1" data-number="5">
<h1 data-number="6"><span class="header-section-number">6</span> Q56 follow-ups</h1> <h1 data-number="5"><span class="header-section-number">5</span> Q56 follow-ups</h1>
<p>caption &lt;- “Christian Denomination” # TODO: copy plot above for Q56 to add two additional plots using climate_experience_data_named<span class="math inline">\(Q56b and climate_experience_data_named\)</span>Q56c # Religious Affiliation b - Christian Denomination Subquestion christian_denomination &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q56b) christian_denomination_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q56b, desc(Count)) christian_denomination_table save_as_docx(christian_denomination_table, path = “./figures/q56_religious_affiliation_xn_denomination.docx”)</p> <p>caption &lt;- “Christian Denomination” # TODO: copy plot above for Q56 to add two additional plots using climate_experience_data_named<span class="math inline">\(Q56b and climate_experience_data_named\)</span>Q56c # Religious Affiliation b - Christian Denomination Subquestion christian_denomination &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q56b) christian_denomination_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q56b, desc(Count)) christian_denomination_table save_as_docx(christian_denomination_table, path = “./figures/q56_religious_affiliation_xn_denomination.docx”)</p>
<p>christian_denomination_hi &lt;- filter(climate_experience_data_named, Q56 == “Christian”, Q57_bin == “high”) christian_denomination_hi &lt;- qualtrics_process_single_multiple_choice(christian_denomination_hi$Q56b) christian_denomination_hi</p> <p>christian_denomination_hi &lt;- filter(climate_experience_data_named, Q56 == “Christian”, Q57_bin == “high”) christian_denomination_hi &lt;- qualtrics_process_single_multiple_choice(christian_denomination_hi$Q56b) christian_denomination_hi</p>
</section> </section>
<section id="religious-affiliation-c---muslim-denomination-subquestion" class="level1" data-number="7"> <section id="religious-affiliation-c---muslim-denomination-subquestion" class="level1" data-number="6">
<h1 data-number="7"><span class="header-section-number">7</span> Religious Affiliation c - Muslim Denomination Subquestion</h1> <h1 data-number="6"><span class="header-section-number">6</span> Religious Affiliation c - Muslim Denomination Subquestion</h1>
<p>caption &lt;- “Islamic Identity” # Should the label be different than income since the data examined is the Affiliation? # TODO: adjust plot to factor using numbered responses on this question (perhaps also above) religious_affiliationc &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q56c) religious_affiliationc_plot &lt;- plot_horizontal_bar(religious_affiliationc) religious_affiliationc_plot &lt;- religious_affiliationc_plot + labs(caption = caption, x = "", y = "") religious_affiliationc_plot ggsave("figures/q56c_religious_affiliation.png", width = 20, height = 10, units = "cm") religious_affiliationc_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q56c, Count) religious_affiliationc_table save_as_docx(religious_affiliationc_table, path = “./figures/q56_religious_affiliation_islam.docx”)</p> <p>caption &lt;- “Islamic Identity” # Should the label be different than income since the data examined is the Affiliation? # TODO: adjust plot to factor using numbered responses on this question (perhaps also above) religious_affiliationc &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q56c) religious_affiliationc_plot &lt;- plot_horizontal_bar(religious_affiliationc) religious_affiliationc_plot &lt;- religious_affiliationc_plot + labs(caption = caption, x = "", y = "") religious_affiliationc_plot ggsave("figures/q56c_religious_affiliation.png", width = 20, height = 10, units = "cm") religious_affiliationc_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q56c, Count) religious_affiliationc_table save_as_docx(religious_affiliationc_table, path = “./figures/q56_religious_affiliation_islam.docx”)</p>
</section> </section>
<section id="q57" class="level1" data-number="8"> <section id="q57" class="level1" data-number="7">
<h1 data-number="8"><span class="header-section-number">8</span> Q57</h1> <h1 data-number="7"><span class="header-section-number">7</span> Q57</h1>
</section> </section>
<section id="religiosity" class="level1" data-number="9"> <section id="religiosity" class="level1" data-number="8">
<h1 data-number="9"><span class="header-section-number">9</span> Religiosity</h1> <h1 data-number="8"><span class="header-section-number">8</span> Religiosity</h1>
<p>caption &lt;- “Respondent Religiosity” religiosity &lt;- qualtrics_process_single_multiple_choice(as.character(climate_experience_data_named<span class="math inline">\(Q57_1)) religiosity_plot &lt;- plot_horizontal_bar(religiosity) religiosity_plot &lt;- religiosity_plot + labs(caption = caption, x = "", y = "") religiosity_plot ggsave("figures/q57_religiosity_plot.png", width = 20, height = 10, units = "cm") religiosity_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q57_1, desc(Variable)) religiosity_table save_as_docx(religious_affiliationc_table, path = “./figures/q57_religiousity.docx”)</p> <p>caption &lt;- “Respondent Religiosity” religiosity &lt;- qualtrics_process_single_multiple_choice(as.character(climate_experience_data_named<span class="math inline">\(Q57_1)) religiosity_plot &lt;- plot_horizontal_bar(religiosity) religiosity_plot &lt;- religiosity_plot + labs(caption = caption, x = "", y = "") religiosity_plot ggsave("figures/q57_religiosity_plot.png", width = 20, height = 10, units = "cm") religiosity_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q57_1, desc(Variable)) religiosity_table save_as_docx(religious_affiliationc_table, path = “./figures/q57_religiousity.docx”)</p>
</section> </section>
<section id="q58" class="level1" data-number="10"> <section id="q58" class="level1" data-number="9">
<h1 data-number="10"><span class="header-section-number">10</span> Q58</h1> <h1 data-number="9"><span class="header-section-number">9</span> Q58</h1>
<p>caption &lt;- “Respondent Attendance of Religious Services” religious_service_attend &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q58) religious_service_attend_plot &lt;- plot_horizontal_bar(religious_service_attend) religious_service_attend_plot &lt;- religious_service_attend_plot + labs(title = caption, x = "", y = "") religious_service_attend_plot ggsave("figures/q58_religious_service_attend.png", width = 20, height = 10, units = "cm") religious_service_attend_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q58, Count) religious_service_attend_table save_as_docx(religious_service_attend_table, path = “./figures/q58_religious_service_attend.docx”)</p> <p>caption &lt;- “Respondent Attendance of Religious Services” religious_service_attend &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q58) religious_service_attend_plot &lt;- plot_horizontal_bar(religious_service_attend) religious_service_attend_plot &lt;- religious_service_attend_plot + labs(title = caption, x = "", y = "") religious_service_attend_plot ggsave("figures/q58_religious_service_attend.png", width = 20, height = 10, units = "cm") religious_service_attend_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q58, Count) religious_service_attend_table save_as_docx(religious_service_attend_table, path = “./figures/q58_religious_service_attend.docx”)</p>
</section> </section>
<section id="faceted-plot-working-with-3x3-grid" class="level1" data-number="11"> <section id="faceted-plot-working-with-3x3-grid" class="level1" data-number="10">
<h1 data-number="11"><span class="header-section-number">11</span> Faceted plot working with 3x3 grid</h1> <h1 data-number="10"><span class="header-section-number">10</span> Faceted plot working with 3x3 grid</h1>
<p>df &lt;- select(climate_experience_data, Q52_bin, Q53_bin, Q57_bin, Q58) names(df) &lt;- c(“Q52_bin”, “Q53_bin”, “Q57_bin”, “response”) facet_names &lt;- c(<code>Q52_bin</code> = “Spirituality”, <code>Q53_bin</code> = “Politics L/R”, <code>Q57_bin</code> = “Religiosity”, <code>low</code>=“low”, <code>medium</code>=“medium”, <code>high</code>=“high”) facet_labeller &lt;- function(variable,value){return(facet_names[value])} df<span class="math inline">\(response &lt;- factor(df\)</span>response, ordered = TRUE, levels = c(“1”, “2”, “3”, “4”, “5”)) df<span class="math inline">\(response &lt;- fct_recode(df\)</span>response, “More than once a week” = “1”, “Once a week” = “2”, “At least once a month” = “3”, “Only on special holy days” = “4”, “Never” = “5”) df %&gt;% # we need to get the data including facet info in long format, so we use pivot_longer() pivot_longer(!response, names_to = “bin_name”, values_to = “b”) %&gt;% # add counts for plot below count(response, bin_name, b) %&gt;% group_by(bin_name,b) %&gt;% mutate(perc=paste0(round(n*100/sum(n),1),“%”)) %&gt;% # run ggplot ggplot(aes(x = n, y = ““, fill = response)) + geom_col(position=position_fill(), aes(fill=response)) + geom_text(aes(label = perc), position = position_fill(vjust=.5), size=2) + scale_fill_brewer(palette =”Dark2”, type = “qual”) + scale_x_continuous(labels = scales::percent_format()) + facet_grid(vars(b), vars(bin_name), labeller=as_labeller(facet_names)) + labs(caption = caption, x = ““, y =”“) + guides(fill = guide_legend(title = NULL)) ggsave(”figures/q58_faceted.png”, width = 30, height = 10, units = “cm”)</p> <p>df &lt;- select(climate_experience_data, Q52_bin, Q53_bin, Q57_bin, Q58) names(df) &lt;- c(“Q52_bin”, “Q53_bin”, “Q57_bin”, “response”) facet_names &lt;- c(<code>Q52_bin</code> = “Spirituality”, <code>Q53_bin</code> = “Politics L/R”, <code>Q57_bin</code> = “Religiosity”, <code>low</code>=“low”, <code>medium</code>=“medium”, <code>high</code>=“high”) facet_labeller &lt;- function(variable,value){return(facet_names[value])} df<span class="math inline">\(response &lt;- factor(df\)</span>response, ordered = TRUE, levels = c(“1”, “2”, “3”, “4”, “5”)) df<span class="math inline">\(response &lt;- fct_recode(df\)</span>response, “More than once a week” = “1”, “Once a week” = “2”, “At least once a month” = “3”, “Only on special holy days” = “4”, “Never” = “5”) df %&gt;% # we need to get the data including facet info in long format, so we use pivot_longer() pivot_longer(!response, names_to = “bin_name”, values_to = “b”) %&gt;% # add counts for plot below count(response, bin_name, b) %&gt;% group_by(bin_name,b) %&gt;% mutate(perc=paste0(round(n*100/sum(n),1),“%”)) %&gt;% # run ggplot ggplot(aes(x = n, y = ““, fill = response)) + geom_col(position=position_fill(), aes(fill=response)) + geom_text(aes(label = perc), position = position_fill(vjust=.5), size=2) + scale_fill_brewer(palette =”Dark2”, type = “qual”) + scale_x_continuous(labels = scales::percent_format()) + facet_grid(vars(b), vars(bin_name), labeller=as_labeller(facet_names)) + labs(caption = caption, x = ““, y =”“) + guides(fill = guide_legend(title = NULL)) ggsave(”figures/q58_faceted.png”, width = 30, height = 10, units = “cm”)</p>
</section> </section>
<section id="q59" class="level1" data-number="12"> <section id="q59" class="level1" data-number="11">
<h1 data-number="12"><span class="header-section-number">12</span> Q59</h1> <h1 data-number="11"><span class="header-section-number">11</span> Q59</h1>
<p>caption &lt;- “Respondent Prayer Outside of Religious Services” prayer &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q59) prayer_plot &lt;- plot_horizontal_bar(prayer) prayer_plot &lt;- prayer_plot + labs(caption = caption, x = "", y = "") prayer_plot ggsave("figures/q59_prayer.png", width = 20, height = 10, units = "cm") prayer_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q59, Count) prayer_table save_as_docx(prayer_table, path = “./figures/q59_prayer.docx”)</p> <p>caption &lt;- “Respondent Prayer Outside of Religious Services” prayer &lt;- qualtrics_process_single_multiple_choice(climate_experience_data_named<span class="math inline">\(Q59) prayer_plot &lt;- plot_horizontal_bar(prayer) prayer_plot &lt;- prayer_plot + labs(caption = caption, x = "", y = "") prayer_plot ggsave("figures/q59_prayer.png", width = 20, height = 10, units = "cm") prayer_table &lt;- chart_single_result_flextable(climate_experience_data_named\)</span>Q59, Count) prayer_table save_as_docx(prayer_table, path = “./figures/q59_prayer.docx”)</p>
</section> </section>
<section id="faceted-plot-working-with-3x3-grid-1" class="level1" data-number="13"> <section id="faceted-plot-working-with-3x3-grid-1" class="level1" data-number="12">
<h1 data-number="13"><span class="header-section-number">13</span> Faceted plot working with 3x3 grid</h1> <h1 data-number="12"><span class="header-section-number">12</span> Faceted plot working with 3x3 grid</h1>
<p>df &lt;- select(climate_experience_data, Q52_bin, Q53_bin, Q57_bin, Q59) names(df) &lt;- c(“Q52_bin”, “Q53_bin”, “Q57_bin”, “response”) facet_names &lt;- c(<code>Q52_bin</code> = “Spirituality”, <code>Q53_bin</code> = “Politics L/R”, <code>Q57_bin</code> = “Religiosity”, <code>low</code>=“low”, <code>medium</code>=“medium”, <code>high</code>=“high”) facet_labeller &lt;- function(variable,value){return(facet_names[value])} df<span class="math inline">\(response &lt;- factor(df\)</span>response, ordered = TRUE, levels = c(“1”, “2”, “3”, “4”, “5”)) df<span class="math inline">\(response &lt;- fct_recode(df\)</span>response, “More than once a week” = “1”, “Once a week” = “2”, “At least once a month” = “3”, “Only on special holy days” = “4”, “Never” = “5”) df %&gt;% # we need to get the data including facet info in long format, so we use pivot_longer() pivot_longer(!response, names_to = “bin_name”, values_to = “b”) %&gt;% # add counts for plot below count(response, bin_name, b) %&gt;% group_by(bin_name,b) %&gt;% mutate(perc=paste0(round(n*100/sum(n),1),“%”)) %&gt;% # run ggplot ggplot(aes(x = n, y = ““, fill = response)) + geom_col(position=position_fill(), aes(fill=response)) + geom_text(aes(label = perc), position = position_fill(vjust=.5), size=2) + scale_fill_brewer(palette =”Dark2”, type = “qual”) + scale_x_continuous(labels = scales::percent_format()) + facet_grid(vars(b), vars(bin_name), labeller=as_labeller(facet_names)) + labs(caption = caption, x = ““, y =”“) + guides(fill = guide_legend(title = NULL)) ggsave(”figures/q59_faceted.png”, width = 30, height = 10, units = “cm”)</p> <p>df &lt;- select(climate_experience_data, Q52_bin, Q53_bin, Q57_bin, Q59) names(df) &lt;- c(“Q52_bin”, “Q53_bin”, “Q57_bin”, “response”) facet_names &lt;- c(<code>Q52_bin</code> = “Spirituality”, <code>Q53_bin</code> = “Politics L/R”, <code>Q57_bin</code> = “Religiosity”, <code>low</code>=“low”, <code>medium</code>=“medium”, <code>high</code>=“high”) facet_labeller &lt;- function(variable,value){return(facet_names[value])} df<span class="math inline">\(response &lt;- factor(df\)</span>response, ordered = TRUE, levels = c(“1”, “2”, “3”, “4”, “5”)) df<span class="math inline">\(response &lt;- fct_recode(df\)</span>response, “More than once a week” = “1”, “Once a week” = “2”, “At least once a month” = “3”, “Only on special holy days” = “4”, “Never” = “5”) df %&gt;% # we need to get the data including facet info in long format, so we use pivot_longer() pivot_longer(!response, names_to = “bin_name”, values_to = “b”) %&gt;% # add counts for plot below count(response, bin_name, b) %&gt;% group_by(bin_name,b) %&gt;% mutate(perc=paste0(round(n*100/sum(n),1),“%”)) %&gt;% # run ggplot ggplot(aes(x = n, y = ““, fill = response)) + geom_col(position=position_fill(), aes(fill=response)) + geom_text(aes(label = perc), position = position_fill(vjust=.5), size=2) + scale_fill_brewer(palette =”Dark2”, type = “qual”) + scale_x_continuous(labels = scales::percent_format()) + facet_grid(vars(b), vars(bin_name), labeller=as_labeller(facet_names)) + labs(caption = caption, x = ““, y =”“) + guides(fill = guide_legend(title = NULL)) ggsave(”figures/q59_faceted.png”, width = 30, height = 10, units = “cm”)</p>
</section> </section>
<section id="comparing-with-attitudes-surrounding-climate-change" class="level1" data-number="14"> <section id="comparing-with-attitudes-surrounding-climate-change" class="level1" data-number="13">
<h1 data-number="14"><span class="header-section-number">14</span> Comparing with attitudes surrounding climate change</h1> <h1 data-number="13"><span class="header-section-number">13</span> Comparing with attitudes surrounding climate change</h1>
</section> </section>
<section id="q6" class="level1" data-number="15"> <section id="q6" class="level1" data-number="14">
<h1 data-number="15"><span class="header-section-number">15</span> Q6</h1> <h1 data-number="14"><span class="header-section-number">14</span> Q6</h1>
<p>q6_data &lt;- qualtrics_process_single_multiple_choice_unsorted_streamlined(climate_experience_data$Q6)</p> <p>q6_data &lt;- qualtrics_process_single_multiple_choice_unsorted_streamlined(climate_experience_data$Q6)</p>
<p>title &lt;- “Do you think the climate is changing?”</p> <p>title &lt;- “Do you think the climate is changing?”</p>
<p>level_order &lt;- c(“Don<e2>&lt;80&gt;&lt;99&gt;t know”, “Definitely not changing”, “Probably not changing”, “Probably changing”, “Definitely changing”) ## code if a specific palette is needed for matching fill = wheel(ochre, num = as.integer(count(q6_data[1]))) # make plot q6_data_plot &lt;- ggplot(q6_data, aes(x = n, y = response, fill = fill)) + geom_col(colour = “white”) + ## add percentage labels geom_text(aes(label = perc), ## make labels left-aligned and white hjust = 1, colour = “black”, size=4) + # use nudge_x = 30, to shift position ## reduce spacing between labels and bars scale_fill_identity(guide = “none”) + ## get rid of all elements except y axis labels + adjust plot margin theme_ipsum_rc() + theme(plot.margin = margin(rep(15, 4))) + easy_center_title() + # with thanks for helpful info on doing wrap here: https://stackoverflow.com/questions/21878974/wrap-long-axis-labels-via-labeller-label-wrap-in-ggplot2 scale_y_discrete(labels = wrap_format(30), limits = level_order) + theme(plot.title = element_text(size =18, hjust = 0.5), axis.text.y = element_text(size =16)) + labs(title = title, x = ““, y =”“)</e2></p> <p>level_order &lt;- c(“Don<e2>&lt;80&gt;&lt;99&gt;t know”, “Definitely not changing”, “Probably not changing”, “Probably changing”, “Definitely changing”) ## code if a specific palette is needed for matching fill = wheel(ochre, num = as.integer(count(q6_data[1]))) # make plot q6_data_plot &lt;- ggplot(q6_data, aes(x = n, y = response, fill = fill)) + geom_col(colour = “white”) + ## add percentage labels geom_text(aes(label = perc), ## make labels left-aligned and white hjust = 1, colour = “black”, size=4) + # use nudge_x = 30, to shift position ## reduce spacing between labels and bars scale_fill_identity(guide = “none”) + ## get rid of all elements except y axis labels + adjust plot margin theme_ipsum_rc() + theme(plot.margin = margin(rep(15, 4))) + easy_center_title() + # with thanks for helpful info on doing wrap here: https://stackoverflow.com/questions/21878974/wrap-long-axis-labels-via-labeller-label-wrap-in-ggplot2 scale_y_discrete(labels = wrap_format(30), limits = level_order) + theme(plot.title = element_text(size =18, hjust = 0.5), axis.text.y = element_text(size =16)) + labs(title = title, x = ““, y =”“)</e2></p>
<p>q6_data_plot</p> <p>q6_data_plot</p>
<p>ggsave(“figures/q6.png”, width = 18, height = 12, units = “cm”)</p> <p>ggsave(“figures/q6.png”, width = 18, height = 12, units = “cm”)</p>
</section> </section>
<section id="subsetting" class="level1" data-number="16"> <section id="subsetting" class="level1" data-number="15">
<h1 data-number="16"><span class="header-section-number">16</span> Subsetting</h1> <h1 data-number="15"><span class="header-section-number">15</span> Subsetting</h1>
<section id="q57-subsetting-based-on-religiosity" class="level2" data-number="16.1"> <section id="q57-subsetting-based-on-religiosity" class="level2" data-number="15.1">
<h2 data-number="16.1" class="anchored" data-anchor-id="q57-subsetting-based-on-religiosity"><span class="header-section-number">16.1</span> Q57 subsetting based on Religiosity ————————————————————–</h2> <h2 data-number="15.1" class="anchored" data-anchor-id="q57-subsetting-based-on-religiosity"><span class="header-section-number">15.1</span> Q57 subsetting based on Religiosity ————————————————————–</h2>
<p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q57_bin = case_when( Q57_1 &gt; mean(Q57_1) + sd(Q57_1) ~ “high”, Q57_1 &lt; mean(Q57_1) - sd(Q57_1) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p> <p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q57_bin = case_when( Q57_1 &gt; mean(Q57_1) + sd(Q57_1) ~ “high”, Q57_1 &lt; mean(Q57_1) - sd(Q57_1) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p>
</section> </section>
<section id="subsetting-based-on-spirituality" class="level2" data-number="16.2"> <section id="subsetting-based-on-spirituality" class="level2" data-number="15.2">
<h2 data-number="16.2" class="anchored" data-anchor-id="subsetting-based-on-spirituality"><span class="header-section-number">16.2</span> Subsetting based on Spirituality ————————————————————–</h2> <h2 data-number="15.2" class="anchored" data-anchor-id="subsetting-based-on-spirituality"><span class="header-section-number">15.2</span> Subsetting based on Spirituality ————————————————————–</h2>
<section id="nature-relatedness" class="level3" data-number="16.2.1"> <section id="nature-relatedness" class="level3" data-number="15.2.1">
<h3 data-number="16.2.1" class="anchored" data-anchor-id="nature-relatedness"><span class="header-section-number">16.2.1</span> Nature relatedness ————————————————————–</h3> <h3 data-number="15.2.1" class="anchored" data-anchor-id="nature-relatedness"><span class="header-section-number">15.2.1</span> Nature relatedness ————————————————————–</h3>
</section> </section>
</section> </section>
</section> </section>
<section id="calculate-overall-mean-nature-relatedness-score-based-on-six-questions" class="level1" data-number="17"> <section id="calculate-overall-mean-nature-relatedness-score-based-on-six-questions" class="level1" data-number="16">
<h1 data-number="17"><span class="header-section-number">17</span> Calculate overall mean nature-relatedness score based on six questions:</h1> <h1 data-number="16"><span class="header-section-number">16</span> Calculate overall mean nature-relatedness score based on six questions:</h1>
<p>climate_experience_data$Q51_score &lt;- rowMeans(select(climate_experience_data, Q51_remote_vacation:Q51_heritage))</p> <p>climate_experience_data$Q51_score &lt;- rowMeans(select(climate_experience_data, Q51_remote_vacation:Q51_heritage))</p>
</section> </section>
<section id="create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" class="level1" data-number="18"> <section id="create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation" class="level1" data-number="17">
<h1 data-number="18"><span class="header-section-number">18</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</h1> <h1 data-number="17"><span class="header-section-number">17</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</h1>
<p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q51_bin = case_when( Q51_score &gt; mean(Q51_score) + sd(Q51_score) ~ “high”, Q51_score &lt; mean(Q51_score) - sd(Q51_score) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p> <p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q51_bin = case_when( Q51_score &gt; mean(Q51_score) + sd(Q51_score) ~ “high”, Q51_score &lt; mean(Q51_score) - sd(Q51_score) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p>
<section id="spirituality-scale" class="level3" data-number="18.0.1"> <section id="spirituality-scale" class="level3" data-number="17.0.1">
<h3 data-number="18.0.1" class="anchored" data-anchor-id="spirituality-scale"><span class="header-section-number">18.0.1</span> Spirituality scale ————————————————————–</h3> <h3 data-number="17.0.1" class="anchored" data-anchor-id="spirituality-scale"><span class="header-section-number">17.0.1</span> Spirituality scale ————————————————————–</h3>
</section> </section>
</section> </section>
<section id="calculate-overall-mean-spirituality-score-based-on-six-questions" class="level1" data-number="19"> <section id="calculate-overall-mean-spirituality-score-based-on-six-questions" class="level1" data-number="18">
<h1 data-number="19"><span class="header-section-number">19</span> Calculate overall mean spirituality score based on six questions:</h1> <h1 data-number="18"><span class="header-section-number">18</span> Calculate overall mean spirituality score based on six questions:</h1>
<p>climate_experience_data$Q52_score &lt;- rowMeans(select(climate_experience_data, Q52a_1:Q52f_1))</p> <p>climate_experience_data$Q52_score &lt;- rowMeans(select(climate_experience_data, Q52a_1:Q52f_1))</p>
</section> </section>
<section id="create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" class="level1" data-number="20"> <section id="create-lowmedhigh-bins-based-on-mean-and-1-1-standard-deviation-1" class="level1" data-number="19">
<h1 data-number="20"><span class="header-section-number">20</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</h1> <h1 data-number="19"><span class="header-section-number">19</span> Create low/med/high bins based on Mean and +1/-1 Standard Deviation</h1>
<p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q52_bin = case_when( Q52_score &gt; mean(Q52_score) + sd(Q52_score) ~ “high”, Q52_score &lt; mean(Q52_score) - sd(Q52_score) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p> <p>climate_experience_data &lt;- climate_experience_data %&gt;% mutate( Q52_bin = case_when( Q52_score &gt; mean(Q52_score) + sd(Q52_score) ~ “high”, Q52_score &lt; mean(Q52_score) - sd(Q52_score) ~ “low”, TRUE ~ “medium” ) %&gt;% factor(levels = c(“low”, “medium”, “high”)) )</p>
<div class="callout callout-style-default callout-tip callout-titled"> <div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center"> <div class="callout-header d-flex align-content-center">
@ -759,12 +765,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
<nav class="page-navigation"> <nav class="page-navigation">
<div class="nav-page nav-page-previous"> <div class="nav-page nav-page-previous">
<a href="./chapter_1.html" class="pagination-link"> <a href="./chapter_1.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span> <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span>
</a> </a>
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./chapter_3.html" class="pagination-link"> <a href="./chapter_3.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 4&nbsp; Mapping churches: geospatial data science</title> <title>Hacking Religion: TRS &amp; Data Science in Action - 3&nbsp; Mapping churches: geospatial data science</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -127,7 +127,7 @@ div.csl-indent {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_3.html"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_3.html"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -161,31 +161,37 @@ div.csl-indent {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link active"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -210,8 +216,8 @@ div.csl-indent {
<h2 id="toc-title">Table of contents</h2> <h2 id="toc-title">Table of contents</h2>
<ul> <ul>
<li><a href="#administrative-shapes---the-uk" id="toc-administrative-shapes---the-uk" class="nav-link active" data-scroll-target="#administrative-shapes---the-uk"><span class="header-section-number">5</span> Administrative shapes - the UK</a></li> <li><a href="#administrative-shapes---the-uk" id="toc-administrative-shapes---the-uk" class="nav-link active" data-scroll-target="#administrative-shapes---the-uk"><span class="header-section-number">4</span> Administrative shapes - the UK</a></li>
<li><a href="#load-in-ordnance-survey-openmap-points-data" id="toc-load-in-ordnance-survey-openmap-points-data" class="nav-link" data-scroll-target="#load-in-ordnance-survey-openmap-points-data"><span class="header-section-number">6</span> Load in Ordnance Survey OpenMap Points Data</a></li> <li><a href="#load-in-ordnance-survey-openmap-points-data" id="toc-load-in-ordnance-survey-openmap-points-data" class="nav-link" data-scroll-target="#load-in-ordnance-survey-openmap-points-data"><span class="header-section-number">5</span> Load in Ordnance Survey OpenMap Points Data</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li> <li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul> </ul>
</nav> </nav>
@ -221,7 +227,7 @@ div.csl-indent {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></h1> <h1 class="title"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></h1>
</div> </div>
@ -243,8 +249,8 @@ div.csl-indent {
<p>The most complex aspect of point data relates to the ways that coordinates are encoded, as they will aways need to be associated with a coordinate reference system (CRS) which describes how they are situated with respect to the planet earth. The most common CRS is the WGS, though for our data sets well also come into contact with the BGS, a specifically British coordinate reference system. There are dozens of CRS, usually mapping onto a specific geographical region. Bearing in mind the way that you need to use a CRS to understand how coordinates can be associated with specific parts of the earth, you can see how this is a bit like survey data, where you also need a “codebook” to understand what the specific response values map onto, e.g.&nbsp;a “1” means “strongly agree” and so on. We also saw, in a previous chapter, how some forms of data have the codebook already baked into the factor data, simplifying the process of interpreting the data. In a similar way, some types of geospatial data sets can also come with CRS “baked in” while well need to define CRS for other types. Here are some of the most common types of geospatial data files:</p> <p>The most complex aspect of point data relates to the ways that coordinates are encoded, as they will aways need to be associated with a coordinate reference system (CRS) which describes how they are situated with respect to the planet earth. The most common CRS is the WGS, though for our data sets well also come into contact with the BGS, a specifically British coordinate reference system. There are dozens of CRS, usually mapping onto a specific geographical region. Bearing in mind the way that you need to use a CRS to understand how coordinates can be associated with specific parts of the earth, you can see how this is a bit like survey data, where you also need a “codebook” to understand what the specific response values map onto, e.g.&nbsp;a “1” means “strongly agree” and so on. We also saw, in a previous chapter, how some forms of data have the codebook already baked into the factor data, simplifying the process of interpreting the data. In a similar way, some types of geospatial data sets can also come with CRS “baked in” while well need to define CRS for other types. Here are some of the most common types of geospatial data files:</p>
<p>CSV: “comma separated values” a plain text file containing various coordinates Shapefile: a legacy file format, often still in use, but being replaced by others for a variety of good reasons. For more on this see [http://switchfromshapefile.org/] Geopackage: one of the more recent ways of packaging up geospatial data. Geopackages can contain a wide variety of different data and are easily portable. GeoJSON: a file format commonly used in other forms of coding, the “JSON” (an acronym for JavaScript Object Notation) is meant to be easily interchangeable across various platforms. GeoJSON is an augmented version of JSON data with coordinates added in.</p> <p>CSV: “comma separated values” a plain text file containing various coordinates Shapefile: a legacy file format, often still in use, but being replaced by others for a variety of good reasons. For more on this see [http://switchfromshapefile.org/] Geopackage: one of the more recent ways of packaging up geospatial data. Geopackages can contain a wide variety of different data and are easily portable. GeoJSON: a file format commonly used in other forms of coding, the “JSON” (an acronym for JavaScript Object Notation) is meant to be easily interchangeable across various platforms. GeoJSON is an augmented version of JSON data with coordinates added in.</p>
<p>Now that you have a sense of some of the basic aspects of geospatial data, lets dive in and do a bit of learning in action.</p> <p>Now that you have a sense of some of the basic aspects of geospatial data, lets dive in and do a bit of learning in action.</p>
<section id="administrative-shapes---the-uk" class="level1" data-number="5"> <section id="administrative-shapes---the-uk" class="level1" data-number="4">
<h1 data-number="5"><span class="header-section-number">5</span> Administrative shapes - the UK</h1> <h1 data-number="4"><span class="header-section-number">4</span> Administrative shapes - the UK</h1>
<p>A good starting point is to aquire some adminstrative data. This is a way of referring to political boundaries, whether country borders or those of a local authority or some other administrative unit. For our purposes, were going to import several different types of administrative boundary which will be used at different points in our visualisations below. Its worth noting that the data we use here was prepared to support the 2011 census, and make use of the shapefile format.</p> <p>A good starting point is to aquire some adminstrative data. This is a way of referring to political boundaries, whether country borders or those of a local authority or some other administrative unit. For our purposes, were going to import several different types of administrative boundary which will be used at different points in our visualisations below. Its worth noting that the data we use here was prepared to support the 2011 census, and make use of the shapefile format.</p>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf) <span class="sc">|&gt;</span> <span class="fu">suppressPackageStartupMessages</span>()</span> <div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf) <span class="sc">|&gt;</span> <span class="fu">suppressPackageStartupMessages</span>()</span>
@ -298,65 +304,62 @@ i Use the conflicted package (&lt;http://conflicted.r-lib.org/&gt;) to force all
</div> </div>
<p>Before we move on, lets plot a simple map and have a look at one of our administrative layers. We can use ggplot with a new type of shape <code>geom_sf()</code> to plot the contents of a geospatial data file with polygons which is loaded as a <code>simplefeature</code> in R.</p> <p>Before we move on, lets plot a simple map and have a look at one of our administrative layers. We can use ggplot with a new type of shape <code>geom_sf()</code> to plot the contents of a geospatial data file with polygons which is loaded as a <code>simplefeature</code> in R.</p>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(bench) <span class="sc">|&gt;</span> <span class="fu">suppressPackageStartupMessages</span>()</span> <div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(uk_countries) <span class="sc">+</span> <span class="fu">geom_sf</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">bench_time</span>(<span class="fu">ggplot</span>(uk_countries) <span class="sc">+</span> <span class="fu">geom_sf</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <div class="cell-output-display">
<div class="cell-output cell-output-stdout"> <p><img src="chapter_3_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid" width="672"></p>
<pre><code>process real
6.83ms 7.05ms </code></pre>
</div> </div>
</div> </div>
</section> </section>
<section id="load-in-ordnance-survey-openmap-points-data" class="level1" data-number="6"> <section id="load-in-ordnance-survey-openmap-points-data" class="level1" data-number="5">
<h1 data-number="6"><span class="header-section-number">6</span> Load in Ordnance Survey OpenMap Points Data</h1> <h1 data-number="5"><span class="header-section-number">5</span> Load in Ordnance Survey OpenMap Points Data</h1>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span> <div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span> <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a></span> <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>os_openmap_pow <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_pow.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span> <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>os_openmap_pow <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_pow.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a></span> <span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="fu">bench_time</span>(<span class="fu">ggplot</span>(os_openmap_pow) <span class="sc">+</span> <span class="fu">geom_sf</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(os_openmap_pow) <span class="sc">+</span> <span class="fu">geom_sf</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout"> <div class="cell-output-display">
<pre><code>process real <p><img src="chapter_3_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid" width="672"></p>
1.17ms 1.15ms </code></pre>
</div> </div>
</div> </div>
<p>Its worth noting that the way that you load geospatial data in R has changed quite dramatically since 2020 with the introduction of the simplefeature class in R. Much of the documentation you will come across “out there” will make reference to a set of functions which are now deprecated.</p> <p>Its worth noting that the way that you load geospatial data in R has changed quite dramatically since 2020 with the introduction of the simplefeature class in R. Much of the documentation you will come across “out there” will make reference to a set of functions which are now deprecated.</p>
<p>Lets use that data weve just loaded to make our first map:</p> <p>Lets use that data weve just loaded to make our first map:</p>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate choropleth map of respondent locations</span></span> <div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate choropleth map of respondent locations</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="co"># using temporary palette here so that 0s are white</span></span> <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co"># using temporary palette here so that 0s are white</span></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tmap) <span class="sc">|&gt;</span> <span class="fu">suppressPackageStartupMessages</span>()</span> <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tmap) <span class="sc">|&gt;</span> <span class="fu">suppressPackageStartupMessages</span>()</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="co"># palette &lt;- c(white, "#a8ddb5", "#43a2ca")</span></span> <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="co"># palette &lt;- c(white, "#a8ddb5", "#43a2ca")</span></span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a></span> <span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>map1 <span class="ot">&lt;-</span> <span class="fu">tm_shape</span>(local_authorities) <span class="sc">+</span> </span> <span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>map1 <span class="ot">&lt;-</span> <span class="fu">tm_shape</span>(local_authorities) <span class="sc">+</span> </span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a><span class="co"># tm_fill(col = "surveys_count", , palette = palette, title = "Concentration of survey respondents") +</span></span> <span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="co"># tm_fill(col = "surveys_count", , palette = palette, title = "Concentration of survey respondents") +</span></span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_borders</span>(<span class="at">alpha=</span>.<span class="dv">5</span>, <span class="at">lwd=</span><span class="fl">0.1</span>) <span class="sc">+</span></span> <span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_borders</span>(<span class="at">alpha=</span>.<span class="dv">5</span>, <span class="at">lwd=</span><span class="fl">0.1</span>) <span class="sc">+</span></span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># for intermediate polygon geometries</span></span> <span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># for intermediate polygon geometries</span></span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_shape(local_authorities) +</span></span> <span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_shape(local_authorities) +</span></span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_borders(lwd=0.6) +</span></span> <span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_borders(lwd=0.6) +</span></span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># for dots from original dataset</span></span> <span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># for dots from original dataset</span></span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_dots("red", size = .05, alpha = .4) +</span></span> <span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_dots("red", size = .05, alpha = .4) +</span></span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_scale_bar</span>(<span class="at">position =</span> <span class="fu">c</span>(<span class="st">"right"</span>, <span class="st">"bottom"</span>)) <span class="sc">+</span></span> <span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_scale_bar</span>(<span class="at">position =</span> <span class="fu">c</span>(<span class="st">"right"</span>, <span class="st">"bottom"</span>)) <span class="sc">+</span></span>
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_style</span>(<span class="st">"gray"</span>) <span class="sc">+</span></span> <span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_style</span>(<span class="st">"gray"</span>) <span class="sc">+</span></span>
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_credits</span>(<span class="st">"Data: UK Data Service (OGL)</span><span class="sc">\n</span><span class="st">&amp; Jeremy H. Kidwell,</span><span class="sc">\n</span><span class="st">Graphic is CC-by-SA 4.0"</span>, </span> <span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_credits</span>(<span class="st">"Data: UK Data Service (OGL)</span><span class="sc">\n</span><span class="st">&amp; Jeremy H. Kidwell,</span><span class="sc">\n</span><span class="st">Graphic is CC-by-SA 4.0"</span>, </span>
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a> <span class="at">size =</span> <span class="fl">0.4</span>, </span> <span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a> <span class="at">size =</span> <span class="fl">0.4</span>, </span>
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span> <span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a> <span class="at">just =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span> <span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a> <span class="at">just =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a> <span class="at">align =</span> <span class="st">"left"</span>) <span class="sc">+</span></span> <span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a> <span class="at">align =</span> <span class="st">"left"</span>) <span class="sc">+</span></span>
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_layout</span>(<span class="at">asp =</span> <span class="cn">NA</span>,</span> <span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_layout</span>(<span class="at">asp =</span> <span class="cn">NA</span>,</span>
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a> <span class="at">frame =</span> <span class="cn">FALSE</span>, </span> <span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a> <span class="at">frame =</span> <span class="cn">FALSE</span>, </span>
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Figure 1a"</span>, </span> <span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Figure 1a"</span>, </span>
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a> <span class="at">title.size =</span> .<span class="dv">7</span>,</span> <span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a> <span class="at">title.size =</span> .<span class="dv">7</span>,</span>
<span id="cb10-25"><a href="#cb10-25" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title.size =</span> .<span class="dv">7</span>,</span> <span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title.size =</span> .<span class="dv">7</span>,</span>
<span id="cb10-26"><a href="#cb10-26" aria-hidden="true" tabindex="-1"></a> <span class="at">inner.margins =</span> <span class="fu">c</span>(<span class="fl">0.1</span>, <span class="fl">0.1</span>, <span class="fl">0.05</span>, <span class="fl">0.05</span>)</span> <span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a> <span class="at">inner.margins =</span> <span class="fu">c</span>(<span class="fl">0.1</span>, <span class="fl">0.1</span>, <span class="fl">0.05</span>, <span class="fl">0.05</span>)</span>
<span id="cb10-27"><a href="#cb10-27" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb10-28"><a href="#cb10-28" aria-hidden="true" tabindex="-1"></a></span> <span id="cb8-28"><a href="#cb8-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-29"><a href="#cb10-29" aria-hidden="true" tabindex="-1"></a>map1</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb8-29"><a href="#cb8-29" aria-hidden="true" tabindex="-1"></a>map1</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display"> <div class="cell-output-display">
<p><img src="chapter_3_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid" width="672"></p> <p><img src="chapter_3_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid" width="672"></p>
</div> </div>
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># save image</span></span> <div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="co"># save image</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">tmap_save</span>(map1, <span class="fu">here</span>(<span class="st">"figures"</span>, <span class="st">"map.png"</span>), <span class="at">width=</span><span class="dv">1920</span>, <span class="at">height=</span><span class="dv">1080</span>, <span class="at">asp=</span><span class="dv">0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">tmap_save</span>(map1, <span class="fu">here</span>(<span class="st">"figures"</span>, <span class="st">"map.png"</span>), <span class="at">width=</span><span class="dv">1920</span>, <span class="at">height=</span><span class="dv">1080</span>, <span class="at">asp=</span><span class="dv">0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr"> <div class="cell-output cell-output-stderr">
<pre><code>Map saved to /Users/kidwellj/gits/hacking_religion_textbook/hacking_religion/figures/map.png</code></pre> <pre><code>Map saved to /Users/kidwellj/gits/hacking_religion_textbook/hacking_religion/figures/map.png</code></pre>
</div> </div>
@ -368,26 +371,26 @@ i Use the conflicted package (&lt;http://conflicted.r-lib.org/&gt;) to force all
</div> </div>
</div> </div>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co"># subsetting ordnance survey openmap data for measuring clusters and proximity</span></span> <div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co"># subsetting ordnance survey openmap data for measuring clusters and proximity</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a>os_openmap_important_buildings <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_important_buildings.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span> <span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>os_openmap_important_buildings <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_important_buildings.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="co"># add pubs, check_cashing, pawnbrokers, SSSI</span></span> <span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="co"># add pubs, check_cashing, pawnbrokers, SSSI</span></span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="do">## subsets</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="do">## subsets</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div> </div>
<ol type="1"> <ol type="1">
<li>Count the number of churches in Local Authorities</li> <li>Count the number of churches in Local Authorities</li>
</ol> </ol>
<div class="cell"> <div class="cell">
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># OSM data</span></span> <div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co"># OSM data</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span> <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span> <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points &lt;- st_read(system.file(here("data", "pow_osm.gpkg", package = "spData")))</span></span> <span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points &lt;- st_read(system.file(here("data", "pow_osm.gpkg", package = "spData")))</span></span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a><span class="co"># vector_filepath = system.file("data/osm-gb-2018Aug29_pow_osm.pbf", package = "sf")</span></span> <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="co"># vector_filepath = system.file("data/osm-gb-2018Aug29_pow_osm.pbf", package = "sf")</span></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points = st_read(vector_filepath)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points = st_read(vector_filepath)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div> </div>
<p>Guides to geographies: https://rconsortium.github.io/censusguide/ https://ocsi.uk/2019/03/18/lsoas-leps-and-lookups-a-beginners-guide-to-statistical-geographies/</p> <p>Guides to geographies: https://rconsortium.github.io/censusguide/ https://ocsi.uk/2019/03/18/lsoas-leps-and-lookups-a-beginners-guide-to-statistical-geographies/</p>
<p>Calculate proximity to pubs</p> <p>Calculate proximity to pubs</p>
@ -638,12 +641,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
<nav class="page-navigation"> <nav class="page-navigation">
<div class="nav-page nav-page-previous"> <div class="nav-page nav-page-previous">
<a href="./chapter_2.html" class="pagination-link"> <a href="./chapter_2.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span> <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span>
</a> </a>
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./chapter_4.html" class="pagination-link"> <a href="./chapter_4.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 133 KiB

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 5&nbsp; Data scraping, corpus analysis and wordclouds</title> <title>Hacking Religion: TRS &amp; Data Science in Action - 4&nbsp; Data scraping, corpus analysis and wordclouds</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -49,7 +49,7 @@ div.csl-indent {
<script src="site_libs/quarto-search/fuse.min.js"></script> <script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script> <script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./"> <meta name="quarto:offset" content="./">
<link href="./summary.html" rel="next"> <link href="./chapter_5.html" rel="next">
<link href="./chapter_3.html" rel="prev"> <link href="./chapter_3.html" rel="prev">
<script src="site_libs/quarto-html/quarto.js"></script> <script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script> <script src="site_libs/quarto-html/popper.min.js"></script>
@ -93,7 +93,7 @@ div.csl-indent {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_4.html"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_4.html"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -127,31 +127,37 @@ div.csl-indent {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link active"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -185,7 +191,7 @@ div.csl-indent {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></h1> <h1 class="title"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></h1>
</div> </div>
@ -446,12 +452,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
<nav class="page-navigation"> <nav class="page-navigation">
<div class="nav-page nav-page-previous"> <div class="nav-page nav-page-previous">
<a href="./chapter_3.html" class="pagination-link"> <a href="./chapter_3.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span> <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span>
</a> </a>
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./summary.html" class="pagination-link"> <a href="./chapter_5.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Summary</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

478
docs/chapter_5.html Normal file
View file

@ -0,0 +1,478 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.3.450">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 5&nbsp; Whats next?</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
<script src="site_libs/quarto-nav/headroom.min.js"></script>
<script src="site_libs/clipboard/clipboard.min.js"></script>
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./">
<link href="./summary.html" rel="next">
<link href="./chapter_4.html" rel="prev">
<script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="site_libs/quarto-html/anchor.min.js"></script>
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script id="quarto-search-options" type="application/json">{
"location": "sidebar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "start",
"type": "textbox",
"limit": 20,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit",
"search-label": "Search"
}
}</script>
</head>
<body class="nav-sidebar floating">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="quarto-secondary-nav">
<div class="container-fluid d-flex">
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i>
</button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_5.html"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">What's next?</span></a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
<i class="bi bi-search"></i>
</button>
</div>
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
<!-- sidebar -->
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal sidebar-navigation floating overflow-auto">
<div class="pt-lg-2 mt-2 text-left sidebar-header">
<div class="sidebar-title mb-0 py-0">
<a href="./">Hacking Religion: TRS &amp; Data Science in Action</a>
</div>
</div>
<div class="mt-2 flex-shrink-0 align-items-center">
<div class="sidebar-search">
<div id="quarto-search" class="" title="Search"></div>
</div>
</div>
<div class="sidebar-menu-container">
<ul class="list-unstyled mt-1">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./index.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">Preface</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">Introduction: Hacking Religion</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./summary.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Summary</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./references.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">References</span></a>
</div>
</li>
</ul>
</div>
</nav>
<div id="quarto-sidebar-glass" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#how-to-get-more-data" id="toc-how-to-get-more-data" class="nav-link active" data-scroll-target="#how-to-get-more-data"><span class="header-section-number">5.1</span> How to get more data</a></li>
<li><a href="#how-to-get-help" id="toc-how-to-get-help" class="nav-link" data-scroll-target="#how-to-get-help"><span class="header-section-number">5.2</span> How to get help</a></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<section id="how-to-get-more-data" class="level2" data-number="5.1">
<h2 data-number="5.1" class="anchored" data-anchor-id="how-to-get-more-data"><span class="header-section-number">5.1</span> How to get more data</h2>
<p>Data can come from a wide variety of places</p>
</section>
<section id="how-to-get-help" class="level2" data-number="5.2">
<h2 data-number="5.2" class="anchored" data-anchor-id="how-to-get-help"><span class="header-section-number">5.2</span> How to get help</h2>
<p>Online forums Etiquette</p>
</section>
<section id="references" class="level1 unnumbered">
<h1 class="unnumbered">References</h1>
<div id="refs" role="list" style="display: none">
</div>
</section>
</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const clipboard = new window.ClipboardJS('.code-copy-button', {
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
<nav class="page-navigation">
<div class="nav-page nav-page-previous">
<a href="./chapter_4.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="./summary.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Summary</span></span> <i class="bi bi-arrow-right-short"></i>
</a>
</div>
</nav>
</div> <!-- /content -->
</body></html>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Jeremy H. Kidwell"> <meta name="author" content="Jeremy H. Kidwell">
<meta name="dcterms.date" content="2023-09-29"> <meta name="dcterms.date" content="2023-10-16">
<title>Hacking Religion: TRS &amp; Data Science in Action</title> <title>Hacking Religion: TRS &amp; Data Science in Action</title>
<style> <style>
@ -109,31 +109,37 @@ ul.task-list li input[type="checkbox"] {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -184,7 +190,7 @@ ul.task-list li input[type="checkbox"] {
<div> <div>
<div class="quarto-title-meta-heading">Published</div> <div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents"> <div class="quarto-title-meta-contents">
<p class="date">September 29, 2023</p> <p class="date">October 16, 2023</p>
</div> </div>
</div> </div>
@ -441,7 +447,7 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./intro.html" class="pagination-link"> <a href="./intro.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text">Introduction: Hacking Religion</span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 1&nbsp; Introduction: Hacking Religion</title> <title>Hacking Religion: TRS &amp; Data Science in Action - Introduction: Hacking Religion</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -74,7 +74,7 @@ ul.task-list li input[type="checkbox"] {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./intro.html"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./intro.html">Introduction: Hacking Religion</a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -108,31 +108,37 @@ ul.task-list li input[type="checkbox"] {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link active"> <a href="./intro.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -157,12 +163,10 @@ ul.task-list li input[type="checkbox"] {
<h2 id="toc-title">Table of contents</h2> <h2 id="toc-title">Table of contents</h2>
<ul> <ul>
<li><a href="#who-this-book-is-for" id="toc-who-this-book-is-for" class="nav-link active" data-scroll-target="#who-this-book-is-for"><span class="header-section-number">1.1</span> Who this book is for</a></li> <li><a href="#why-this-book" id="toc-why-this-book" class="nav-link active" data-scroll-target="#why-this-book">Why this book?</a></li>
<li><a href="#why-this-book" id="toc-why-this-book" class="nav-link" data-scroll-target="#why-this-book"><span class="header-section-number">1.2</span> Why this book?</a></li> <li><a href="#the-hacker-way" id="toc-the-hacker-way" class="nav-link" data-scroll-target="#the-hacker-way">The hacker way</a></li>
<li><a href="#the-hacker-way" id="toc-the-hacker-way" class="nav-link" data-scroll-target="#the-hacker-way"><span class="header-section-number">1.3</span> The hacker way</a></li> <li><a href="#learning-to-code-my-way" id="toc-learning-to-code-my-way" class="nav-link" data-scroll-target="#learning-to-code-my-way">Learning to code: my way</a></li>
<li><a href="#why-programmatic-data-science" id="toc-why-programmatic-data-science" class="nav-link" data-scroll-target="#why-programmatic-data-science"><span class="header-section-number">1.4</span> Why programmatic data science?</a></li> <li><a href="#getting-set-up" id="toc-getting-set-up" class="nav-link" data-scroll-target="#getting-set-up">Getting set up</a></li>
<li><a href="#learning-to-code-my-way" id="toc-learning-to-code-my-way" class="nav-link" data-scroll-target="#learning-to-code-my-way"><span class="header-section-number">1.5</span> Learning to code: my way</a></li>
<li><a href="#getting-set-up" id="toc-getting-set-up" class="nav-link" data-scroll-target="#getting-set-up"><span class="header-section-number">1.6</span> Getting set up</a></li>
</ul> </ul>
</nav> </nav>
</div> </div>
@ -171,7 +175,7 @@ ul.task-list li input[type="checkbox"] {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></h1> <h1 class="title">Introduction: Hacking Religion</h1>
</div> </div>
@ -186,33 +190,33 @@ ul.task-list li input[type="checkbox"] {
</header> </header>
<section id="who-this-book-is-for" class="level2" data-number="1.1"> <section id="why-this-book" class="level2">
<h2 data-number="1.1" class="anchored" data-anchor-id="who-this-book-is-for"><span class="header-section-number">1.1</span> Who this book is for</h2> <h2 class="anchored" data-anchor-id="why-this-book">Why this book?</h2>
<p>Data science is quickly consolidating as a new field, with new tools and user communities emerging seemingly every week! At the same time the field of academic research has opened up into new interdisciplinary vistas, with experts crossing over into new fields, transgressing disciplinary boundaries and deploying tools in new and unexpected ways to develop knowledge. There are many gaps yet to be filled, but one which I found to be particularly glaring is the lack of applied data science documentation around the subject of religion. On one hand, scholars who are working with cutting edge theory seldom pick up the emerging tools of data science. On the other hand, data scientists rarely go beyond dabbling in religious themes. This book aims to bring these two things together: introducing the tools of data science in an applied way, whilst introducing some of the complexities and cutting edge theories which help us to conceptualise and frame our understanding of this knowledge.</p>
</section> </section>
<section id="why-this-book" class="level2" data-number="1.2"> <section id="the-hacker-way" class="level2">
<h2 data-number="1.2" class="anchored" data-anchor-id="why-this-book"><span class="header-section-number">1.2</span> Why this book?</h2> <h2 class="anchored" data-anchor-id="the-hacker-way">The hacker way</h2>
</section> <p>Its worth emphasising at the outset that this isnt meant to be a generic data science book. My own training as a researcher lies in the field of religious ethics, and my engagement with digital technology has, from the very start, been a context for exploring matters of personal values, and social action. A fair bit of ink has been spilled in books, magazines, blogs, zines, and tweets unpacking what exactly it means to be a “hacker”. Pressing beyond some of the more superficial cultural stereotypes, I want to explain a bit here about how hacking can be a much more substantial vision for ethical engagement with technology and social transformation.</p>
<section id="the-hacker-way" class="level2" data-number="1.3"> <p>Back in the 1980s Steven Levy tried to capture some of this in his book “Hackers: Heroes of the Computer Revolution”. As Levy put it, the “hacker ethic” included: (1) sharing, (2) openness, (3) decentralisation, (4) free access to computers and (5) world improvement. The key point here is that hacking isnt just about writing and breaking code, or testing and finding weaknesses in computer systems and networks. It can be a more substantial ethical code.</p>
<h2 data-number="1.3" class="anchored" data-anchor-id="the-hacker-way"><span class="header-section-number">1.3</span> The hacker way</h2> <p>This emphasis on ethics is especially important when were doing data science because this kind of research work will put you in positions of influence and grant you power over others. You might think this seems a bit overstated, but it never ceases to amaze me how much bringing a bar chart which succinctly shows some sort of social trend can sway a conversation or decision making process. There is something unusually persuasive that comes with the combination of aesthetics, data and storytelling. Ive met many people who have come to data science out of a desire to bring about social transformation in some sphere of life. People want to use technology and communication to make the world better. However, its possible that this can quickly get out of hand. Its important to have a clear sense of what sorts of convictions guide your work in this field, a “hacker code” of sorts. With this in mind, Id like to share with you my own set of principles:</p>
<p>It never ceases to amaze me how often people think that, when theyre working for something they think is important it is acceptable to conceal bad news or amplify good or compelling information beyond its real scope. There are always consequences, eventually. When people realise youve been misleading or manipulating them your platform and credibility will evaporate. Good work mixed with bad will all get tossed out. And sometimes, our convictions can lead us beyond our true apprehension of a situation.</p>
<p>Presenting through “facts” an argument can become unnaturally compelling. Wrapping those facts up in something that uses colour, line and shape in a way that is aesthetically pleasing, even beautiful, enhances this allure even further. As you take up the hacker way, its vitally important that you always strive to tell the truth. This includes a willingness to acknowledge the limits of your information, and to share the whole set of information. The easiest way to do this is to work with visualation in a responsible way (Ill get into this a bit more in Chapter 1) and to open up your data and code to scrutiny. By allowing others to try, criticise, edit, and reappropriate your code and data in their own ways, you contribute to knowledge help to build up a community of accountability. The upside of this is that its also a lot more fun and interesting to work alongside others.</p>
<p>Far too often, scholarly research (and theology) has been criticised for being disconnected from reality, making abstract pie-in-the-sky claims about how life should be lived. When exposed to the uncomfortable pressures of reality, these claims can crumble, or even turn sinister. One of the upsides of working with empirical research is that you have a chance to engage with the real world. For this reason, I love to do ethics in a way that arises - bottom-up - from real world experiences and relationships. Theres also the potential that when we make choices based on reliable information drawn from everyday reality like this our policy and culture can be more resilient and accountable. This also works well with the hacker ethos of “learning by doing” and its this approach that guides my approach in this book. This isnt just a book about data analysis, Im proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that youll gain access to a set of tools and a research philosophy which is much more powerful.</p>
<p>Heres a quick summary of these principles, which Ill return to periodically as we work through the coding and data in this book:</p>
<ol type="1"> <ol type="1">
<li><p>Tell the truth</p></li> <li>Tell the truth: Be candid about your limits, use visualisation responsibly</li>
<li><p>Do not deceive using beauty</p></li> <li>Work transparently: Open data, open code</li>
<li><p>Work transparently: research as open code using open data</p></li> <li>Work in community, draw others in by producing reproducible research</li>
<li><p>Draw others in: produce reproducible research</p></li> <li>Work with reality, learn by doing</li>
<li><p>Learn by doing</p></li>
</ol> </ol>
</section> </section>
<section id="why-programmatic-data-science" class="level2" data-number="1.4"> <section id="learning-to-code-my-way" class="level2">
<h2 data-number="1.4" class="anchored" data-anchor-id="why-programmatic-data-science"><span class="header-section-number">1.4</span> Why programmatic data science?</h2> <h2 class="anchored" data-anchor-id="learning-to-code-my-way">Learning to code: my way</h2>
<p>This isnt just a book about data analysis, Im proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that youll gain access to a set of tools and a research philosophy which is much more powerful.</p> <p>This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, the logical structure of algorithms or whatever. It was usuallyweeks of reading before I got to actually <em>do</em> anything. I know some people may prefer this approach, but I prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so its not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices Ive made and the way Ive structured things. Each chapter focusses on a <em>problem</em> which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a “deep dive” when you feel like it. Otherwise, Ill take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.</p>
</section>
<section id="learning-to-code-my-way" class="level2" data-number="1.5">
<h2 data-number="1.5" class="anchored" data-anchor-id="learning-to-code-my-way"><span class="header-section-number">1.5</span> Learning to code: my way</h2>
<p>This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, or whatever, such that it was weeks before I got to actually <em>do</em> anything. I know some people, may prefer this approach, but I dramatically prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so its not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices Ive made and the way Ive structured things. Each chapter focusses on a <em>problem</em> which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a “deep dive” when you feel like it. Otherwise, Ill take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.</p>
<p>There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, Id recommend that many readers will want to check out Hadley Wickhams “R For Data Science” book. Ill include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail.</p> <p>There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, Id recommend that many readers will want to check out Hadley Wickhams “R For Data Science” book. Ill include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail.</p>
</section> </section>
<section id="getting-set-up" class="level2" data-number="1.6"> <section id="getting-set-up" class="level2">
<h2 data-number="1.6" class="anchored" data-anchor-id="getting-set-up"><span class="header-section-number">1.6</span> Getting set up</h2> <h2 class="anchored" data-anchor-id="getting-set-up">Getting set up</h2>
<p>Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the “hacker way”) theyve made these tools freely available. This also means that you arent restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. Ill make a few opinionated recommendations here based on my own preferences and experience, but its really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools youve found that you want to share with others.</p> <p>Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the “hacker way”) theyve made these tools freely available. This also means that you arent restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. Ill make a few opinionated recommendations here based on my own preferences and experience, but its really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools youve found that you want to share with others.</p>
<p>There are, right now, primarily two languages that statisticians and data scientists use for this kind of programmatic data science: python and R. Each language has its merits and I wont rehash the debates between various factions. For this book, well be using the R language. This is, in part, because the R user community and libraries tend to scale a bit better for the work that Im commending in this book. However, its entirely possible that one could use python for all these exercises, and perhaps in the future well have volume two of this book outlining python approaches to the same operations.</p> <p>There are, right now, primarily two languages that statisticians and data scientists use for this kind of programmatic data science: python and R. Each language has its merits and I wont rehash the debates between various factions. For this book, well be using the R language. This is, in part, because the R user community and libraries tend to scale a bit better for the work that Im commending in this book. However, its entirely possible that one could use python for all these exercises, and perhaps in the future well have volume two of this book outlining python approaches to the same operations.</p>
<p>Bearing this in mind, the first step youll need to take is to download and install R. You can find instructions and install packages for a wide range of hardware on the The Comprehensive R Archive Network (or “CRAN”): https://cran.rstudio.com. Once youve installed R, youve got some choices to make about the kind of programming environment youd like to use. You can just use a plain text editor like <code>textedit</code> to write your code and then execute your programs using the R software youve just installed. However, most users, myself included, tend to use an integrated development environment (or “IDE”). This is usually another software package with a guided user interface and some visual elements that make it faster to write and test your code. Some IDE packages, will have built-in reference tools so you can look up options for libraries you use in your code, they will allow you to visualise the results of your code execution, and perhaps most important of all, will enable you to execute your programs line by line so you can spot errors more quickly (we call this “debugging”). The two most popular IDE platforms for R coding at the time of writing this textbook are RStudio and Visual Studio. You should download and try out both and stick with your favourite, as the differences are largely aesthetic. I use a combination of RStudio and an enhanced plain text editor Sublime Text for my coding.</p> <p>Bearing this in mind, the first step youll need to take is to download and install R. You can find instructions and install packages for a wide range of hardware on the The Comprehensive R Archive Network (or “CRAN”): https://cran.rstudio.com. Once youve installed R, youve got some choices to make about the kind of programming environment youd like to use. You can just use a plain text editor like <code>textedit</code> to write your code and then execute your programs using the R software youve just installed. However, most users, myself included, tend to use an integrated development environment (or “IDE”). This is usually another software package with a guided user interface and some visual elements that make it faster to write and test your code. Some IDE packages, will have built-in reference tools so you can look up options for libraries you use in your code, they will allow you to visualise the results of your code execution, and perhaps most important of all, will enable you to execute your programs line by line so you can spot errors more quickly (we call this “debugging”). The two most popular IDE platforms for R coding at the time of writing this textbook are RStudio and Visual Studio. You should download and try out both and stick with your favourite, as the differences are largely aesthetic. I use a combination of RStudio and an enhanced plain text editor Sublime Text for my coding.</p>
@ -463,7 +467,7 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./chapter_1.html" class="pagination-link"> <a href="./chapter_1.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

View file

@ -126,31 +126,37 @@ div.csl-indent {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">

File diff suppressed because one or more lines are too long

View file

@ -31,7 +31,7 @@ ul.task-list li input[type="checkbox"] {
<script src="site_libs/quarto-search/quarto-search.js"></script> <script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./"> <meta name="quarto:offset" content="./">
<link href="./references.html" rel="next"> <link href="./references.html" rel="next">
<link href="./chapter_4.html" rel="prev"> <link href="./chapter_5.html" rel="prev">
<script src="site_libs/quarto-html/quarto.js"></script> <script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script> <script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script> <script src="site_libs/quarto-html/tippy.umd.min.js"></script>
@ -108,31 +108,37 @@ ul.task-list li input[type="checkbox"] {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -415,8 +421,8 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
</script> </script>
<nav class="page-navigation"> <nav class="page-navigation">
<div class="nav-page nav-page-previous"> <div class="nav-page nav-page-previous">
<a href="./chapter_4.html" class="pagination-link"> <a href="./chapter_5.html" class="pagination-link">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span> <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span>
</a> </a>
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Jeremy H. Kidwell"> <meta name="author" content="Jeremy H. Kidwell">
<meta name="dcterms.date" content="2023-09-29"> <meta name="dcterms.date" content="2023-10-16">
<title>Hacking Religion: TRS &amp; Data Science in Action</title> <title>Hacking Religion: TRS &amp; Data Science in Action</title>
<style> <style>
@ -109,31 +109,37 @@ ul.task-list li input[type="checkbox"] {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link"> <a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -184,7 +190,7 @@ ul.task-list li input[type="checkbox"] {
<div> <div>
<div class="quarto-title-meta-heading">Published</div> <div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents"> <div class="quarto-title-meta-contents">
<p class="date">September 29, 2023</p> <p class="date">October 16, 2023</p>
</div> </div>
</div> </div>
@ -441,7 +447,7 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./intro.html" class="pagination-link"> <a href="./intro.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text">Introduction: Hacking Religion</span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Hacking Religion: TRS &amp; Data Science in Action - 1&nbsp; Introduction: Hacking Religion</title> <title>Hacking Religion: TRS &amp; Data Science in Action - Introduction: Hacking Religion</title>
<style> <style>
code{white-space: pre-wrap;} code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;} span.smallcaps{font-variant: small-caps;}
@ -74,7 +74,7 @@ ul.task-list li input[type="checkbox"] {
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i> <i class="bi bi-layout-text-sidebar-reverse"></i>
</button> </button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./intro.html"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></a></li></ol></nav> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./intro.html">Introduction: Hacking Religion</a></li></ol></nav>
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a> </a>
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();"> <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
@ -108,31 +108,37 @@ ul.task-list li input[type="checkbox"] {
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link active"> <a href="./intro.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></span></a> <span class="menu-text">Introduction: Hacking Religion</span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a> <span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a> <span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a> <span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
<div class="sidebar-item-container"> <div class="sidebar-item-container">
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link"> <a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a> <span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Whats next?</span></span></a>
</div> </div>
</li> </li>
<li class="sidebar-item"> <li class="sidebar-item">
@ -157,12 +163,10 @@ ul.task-list li input[type="checkbox"] {
<h2 id="toc-title">Table of contents</h2> <h2 id="toc-title">Table of contents</h2>
<ul> <ul>
<li><a href="#who-this-book-is-for" id="toc-who-this-book-is-for" class="nav-link active" data-scroll-target="#who-this-book-is-for"><span class="header-section-number">1.1</span> Who this book is for</a></li> <li><a href="#why-this-book" id="toc-why-this-book" class="nav-link active" data-scroll-target="#why-this-book">Why this book?</a></li>
<li><a href="#why-this-book" id="toc-why-this-book" class="nav-link" data-scroll-target="#why-this-book"><span class="header-section-number">1.2</span> Why this book?</a></li> <li><a href="#the-hacker-way" id="toc-the-hacker-way" class="nav-link" data-scroll-target="#the-hacker-way">The hacker way</a></li>
<li><a href="#the-hacker-way" id="toc-the-hacker-way" class="nav-link" data-scroll-target="#the-hacker-way"><span class="header-section-number">1.3</span> The hacker way</a></li> <li><a href="#learning-to-code-my-way" id="toc-learning-to-code-my-way" class="nav-link" data-scroll-target="#learning-to-code-my-way">Learning to code: my way</a></li>
<li><a href="#why-programmatic-data-science" id="toc-why-programmatic-data-science" class="nav-link" data-scroll-target="#why-programmatic-data-science"><span class="header-section-number">1.4</span> Why programmatic data science?</a></li> <li><a href="#getting-set-up" id="toc-getting-set-up" class="nav-link" data-scroll-target="#getting-set-up">Getting set up</a></li>
<li><a href="#learning-to-code-my-way" id="toc-learning-to-code-my-way" class="nav-link" data-scroll-target="#learning-to-code-my-way"><span class="header-section-number">1.5</span> Learning to code: my way</a></li>
<li><a href="#getting-set-up" id="toc-getting-set-up" class="nav-link" data-scroll-target="#getting-set-up"><span class="header-section-number">1.6</span> Getting set up</a></li>
</ul> </ul>
</nav> </nav>
</div> </div>
@ -171,7 +175,7 @@ ul.task-list li input[type="checkbox"] {
<header id="title-block-header" class="quarto-title-block default"> <header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title"> <div class="quarto-title">
<h1 class="title"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction: Hacking Religion</span></h1> <h1 class="title">Introduction: Hacking Religion</h1>
</div> </div>
@ -186,33 +190,33 @@ ul.task-list li input[type="checkbox"] {
</header> </header>
<section id="who-this-book-is-for" class="level2" data-number="1.1"> <section id="why-this-book" class="level2">
<h2 data-number="1.1" class="anchored" data-anchor-id="who-this-book-is-for"><span class="header-section-number">1.1</span> Who this book is for</h2> <h2 class="anchored" data-anchor-id="why-this-book">Why this book?</h2>
<p>Data science is quickly consolidating as a new field, with new tools and user communities emerging seemingly every week! At the same time the field of academic research has opened up into new interdisciplinary vistas, with experts crossing over into new fields, transgressing disciplinary boundaries and deploying tools in new and unexpected ways to develop knowledge. There are many gaps yet to be filled, but one which I found to be particularly glaring is the lack of applied data science documentation around the subject of religion. On one hand, scholars who are working with cutting edge theory seldom pick up the emerging tools of data science. On the other hand, data scientists rarely go beyond dabbling in religious themes. This book aims to bring these two things together: introducing the tools of data science in an applied way, whilst introducing some of the complexities and cutting edge theories which help us to conceptualise and frame our understanding of this knowledge.</p>
</section> </section>
<section id="why-this-book" class="level2" data-number="1.2"> <section id="the-hacker-way" class="level2">
<h2 data-number="1.2" class="anchored" data-anchor-id="why-this-book"><span class="header-section-number">1.2</span> Why this book?</h2> <h2 class="anchored" data-anchor-id="the-hacker-way">The hacker way</h2>
</section> <p>Its worth emphasising at the outset that this isnt meant to be a generic data science book. My own training as a researcher lies in the field of religious ethics, and my engagement with digital technology has, from the very start, been a context for exploring matters of personal values, and social action. A fair bit of ink has been spilled in books, magazines, blogs, zines, and tweets unpacking what exactly it means to be a “hacker”. Pressing beyond some of the more superficial cultural stereotypes, I want to explain a bit here about how hacking can be a much more substantial vision for ethical engagement with technology and social transformation.</p>
<section id="the-hacker-way" class="level2" data-number="1.3"> <p>Back in the 1980s Steven Levy tried to capture some of this in his book “Hackers: Heroes of the Computer Revolution”. As Levy put it, the “hacker ethic” included: (1) sharing, (2) openness, (3) decentralisation, (4) free access to computers and (5) world improvement. The key point here is that hacking isnt just about writing and breaking code, or testing and finding weaknesses in computer systems and networks. It can be a more substantial ethical code.</p>
<h2 data-number="1.3" class="anchored" data-anchor-id="the-hacker-way"><span class="header-section-number">1.3</span> The hacker way</h2> <p>This emphasis on ethics is especially important when were doing data science because this kind of research work will put you in positions of influence and grant you power over others. You might think this seems a bit overstated, but it never ceases to amaze me how much bringing a bar chart which succinctly shows some sort of social trend can sway a conversation or decision making process. There is something unusually persuasive that comes with the combination of aesthetics, data and storytelling. Ive met many people who have come to data science out of a desire to bring about social transformation in some sphere of life. People want to use technology and communication to make the world better. However, its possible that this can quickly get out of hand. Its important to have a clear sense of what sorts of convictions guide your work in this field, a “hacker code” of sorts. With this in mind, Id like to share with you my own set of principles:</p>
<p>It never ceases to amaze me how often people think that, when theyre working for something they think is important it is acceptable to conceal bad news or amplify good or compelling information beyond its real scope. There are always consequences, eventually. When people realise youve been misleading or manipulating them your platform and credibility will evaporate. Good work mixed with bad will all get tossed out. And sometimes, our convictions can lead us beyond our true apprehension of a situation.</p>
<p>Presenting through “facts” an argument can become unnaturally compelling. Wrapping those facts up in something that uses colour, line and shape in a way that is aesthetically pleasing, even beautiful, enhances this allure even further. As you take up the hacker way, its vitally important that you always strive to tell the truth. This includes a willingness to acknowledge the limits of your information, and to share the whole set of information. The easiest way to do this is to work with visualation in a responsible way (Ill get into this a bit more in Chapter 1) and to open up your data and code to scrutiny. By allowing others to try, criticise, edit, and reappropriate your code and data in their own ways, you contribute to knowledge help to build up a community of accountability. The upside of this is that its also a lot more fun and interesting to work alongside others.</p>
<p>Far too often, scholarly research (and theology) has been criticised for being disconnected from reality, making abstract pie-in-the-sky claims about how life should be lived. When exposed to the uncomfortable pressures of reality, these claims can crumble, or even turn sinister. One of the upsides of working with empirical research is that you have a chance to engage with the real world. For this reason, I love to do ethics in a way that arises - bottom-up - from real world experiences and relationships. Theres also the potential that when we make choices based on reliable information drawn from everyday reality like this our policy and culture can be more resilient and accountable. This also works well with the hacker ethos of “learning by doing” and its this approach that guides my approach in this book. This isnt just a book about data analysis, Im proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that youll gain access to a set of tools and a research philosophy which is much more powerful.</p>
<p>Heres a quick summary of these principles, which Ill return to periodically as we work through the coding and data in this book:</p>
<ol type="1"> <ol type="1">
<li><p>Tell the truth</p></li> <li>Tell the truth: Be candid about your limits, use visualisation responsibly</li>
<li><p>Do not deceive using beauty</p></li> <li>Work transparently: Open data, open code</li>
<li><p>Work transparently: research as open code using open data</p></li> <li>Work in community, draw others in by producing reproducible research</li>
<li><p>Draw others in: produce reproducible research</p></li> <li>Work with reality, learn by doing</li>
<li><p>Learn by doing</p></li>
</ol> </ol>
</section> </section>
<section id="why-programmatic-data-science" class="level2" data-number="1.4"> <section id="learning-to-code-my-way" class="level2">
<h2 data-number="1.4" class="anchored" data-anchor-id="why-programmatic-data-science"><span class="header-section-number">1.4</span> Why programmatic data science?</h2> <h2 class="anchored" data-anchor-id="learning-to-code-my-way">Learning to code: my way</h2>
<p>This isnt just a book about data analysis, Im proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that youll gain access to a set of tools and a research philosophy which is much more powerful.</p> <p>This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, the logical structure of algorithms or whatever. It was usuallyweeks of reading before I got to actually <em>do</em> anything. I know some people may prefer this approach, but I prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so its not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices Ive made and the way Ive structured things. Each chapter focusses on a <em>problem</em> which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a “deep dive” when you feel like it. Otherwise, Ill take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.</p>
</section>
<section id="learning-to-code-my-way" class="level2" data-number="1.5">
<h2 data-number="1.5" class="anchored" data-anchor-id="learning-to-code-my-way"><span class="header-section-number">1.5</span> Learning to code: my way</h2>
<p>This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, or whatever, such that it was weeks before I got to actually <em>do</em> anything. I know some people, may prefer this approach, but I dramatically prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so its not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices Ive made and the way Ive structured things. Each chapter focusses on a <em>problem</em> which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a “deep dive” when you feel like it. Otherwise, Ill take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.</p>
<p>There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, Id recommend that many readers will want to check out Hadley Wickhams “R For Data Science” book. Ill include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail.</p> <p>There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, Id recommend that many readers will want to check out Hadley Wickhams “R For Data Science” book. Ill include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail.</p>
</section> </section>
<section id="getting-set-up" class="level2" data-number="1.6"> <section id="getting-set-up" class="level2">
<h2 data-number="1.6" class="anchored" data-anchor-id="getting-set-up"><span class="header-section-number">1.6</span> Getting set up</h2> <h2 class="anchored" data-anchor-id="getting-set-up">Getting set up</h2>
<p>Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the “hacker way”) theyve made these tools freely available. This also means that you arent restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. Ill make a few opinionated recommendations here based on my own preferences and experience, but its really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools youve found that you want to share with others.</p> <p>Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the “hacker way”) theyve made these tools freely available. This also means that you arent restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. Ill make a few opinionated recommendations here based on my own preferences and experience, but its really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools youve found that you want to share with others.</p>
<p>There are, right now, primarily two languages that statisticians and data scientists use for this kind of programmatic data science: python and R. Each language has its merits and I wont rehash the debates between various factions. For this book, well be using the R language. This is, in part, because the R user community and libraries tend to scale a bit better for the work that Im commending in this book. However, its entirely possible that one could use python for all these exercises, and perhaps in the future well have volume two of this book outlining python approaches to the same operations.</p> <p>There are, right now, primarily two languages that statisticians and data scientists use for this kind of programmatic data science: python and R. Each language has its merits and I wont rehash the debates between various factions. For this book, well be using the R language. This is, in part, because the R user community and libraries tend to scale a bit better for the work that Im commending in this book. However, its entirely possible that one could use python for all these exercises, and perhaps in the future well have volume two of this book outlining python approaches to the same operations.</p>
<p>Bearing this in mind, the first step youll need to take is to download and install R. You can find instructions and install packages for a wide range of hardware on the The Comprehensive R Archive Network (or “CRAN”): https://cran.rstudio.com. Once youve installed R, youve got some choices to make about the kind of programming environment youd like to use. You can just use a plain text editor like <code>textedit</code> to write your code and then execute your programs using the R software youve just installed. However, most users, myself included, tend to use an integrated development environment (or “IDE”). This is usually another software package with a guided user interface and some visual elements that make it faster to write and test your code. Some IDE packages, will have built-in reference tools so you can look up options for libraries you use in your code, they will allow you to visualise the results of your code execution, and perhaps most important of all, will enable you to execute your programs line by line so you can spot errors more quickly (we call this “debugging”). The two most popular IDE platforms for R coding at the time of writing this textbook are RStudio and Visual Studio. You should download and try out both and stick with your favourite, as the differences are largely aesthetic. I use a combination of RStudio and an enhanced plain text editor Sublime Text for my coding.</p> <p>Bearing this in mind, the first step youll need to take is to download and install R. You can find instructions and install packages for a wide range of hardware on the The Comprehensive R Archive Network (or “CRAN”): https://cran.rstudio.com. Once youve installed R, youve got some choices to make about the kind of programming environment youd like to use. You can just use a plain text editor like <code>textedit</code> to write your code and then execute your programs using the R software youve just installed. However, most users, myself included, tend to use an integrated development environment (or “IDE”). This is usually another software package with a guided user interface and some visual elements that make it faster to write and test your code. Some IDE packages, will have built-in reference tools so you can look up options for libraries you use in your code, they will allow you to visualise the results of your code execution, and perhaps most important of all, will enable you to execute your programs line by line so you can spot errors more quickly (we call this “debugging”). The two most popular IDE platforms for R coding at the time of writing this textbook are RStudio and Visual Studio. You should download and try out both and stick with your favourite, as the differences are largely aesthetic. I use a combination of RStudio and an enhanced plain text editor Sublime Text for my coding.</p>
@ -463,7 +467,7 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
</div> </div>
<div class="nav-page nav-page-next"> <div class="nav-page nav-page-next">
<a href="./chapter_1.html" class="pagination-link"> <a href="./chapter_1.html" class="pagination-link">
<span class="nav-page-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span> <i class="bi bi-arrow-right-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">The 2021 UK Census</span></span> <i class="bi bi-arrow-right-short"></i>
</a> </a>
</div> </div>
</nav> </nav>

View file

@ -4,7 +4,7 @@ project:
book: book:
title: "Hacking Religion: TRS & Data Science in Action" title: "Hacking Religion: TRS & Data Science in Action"
author: "Jeremy H. Kidwell" author: "Jeremy H. Kidwell"
date: "9/29/2023" date: "10/16/2023"
chapters: chapters:
- index.qmd - index.qmd
- intro.qmd - intro.qmd
@ -12,6 +12,7 @@ book:
- chapter_2.qmd - chapter_2.qmd
- chapter_3.qmd - chapter_3.qmd
- chapter_4.qmd - chapter_4.qmd
- chapter_5.qmd
- summary.qmd - summary.qmd
- references.qmd - references.qmd
@ -24,5 +25,6 @@ format:
pdf: pdf:
documentclass: scrreprt documentclass: scrreprt
knitr:
opts_chunk:
dev: ragg_png

View file

@ -371,7 +371,5 @@ plot1 <- ggplot(uk_census_merged_religion_ethnicity, aes(fill=Year, x=Religion,
ggsave("chart.png", plot=plot1, width = 8, height = 10, units=c("in")) ggsave("chart.png", plot=plot1, width = 8, height = 10, units=c("in"))
``` ```
# References {.unnumbered}
::: {#refs} ::: {#refs}
::: :::

View file

@ -60,8 +60,7 @@ local_authorities_buildings_clip <- st_read(here("data", "infuse_dist_lyr_2011_s
Before we move on, let's plot a simple map and have a look at one of our administrative layers. We can use ggplot with a new type of shape `geom_sf()` to plot the contents of a geospatial data file with polygons which is loaded as a `simplefeature` in R. Before we move on, let's plot a simple map and have a look at one of our administrative layers. We can use ggplot with a new type of shape `geom_sf()` to plot the contents of a geospatial data file with polygons which is loaded as a `simplefeature` in R.
```{r} ```{r}
library(bench) |> suppressPackageStartupMessages() ggplot(uk_countries) + geom_sf()
bench_time(ggplot(uk_countries) + geom_sf())
``` ```
# Load in Ordnance Survey OpenMap Points Data # Load in Ordnance Survey OpenMap Points Data
@ -72,7 +71,7 @@ bench_time(ggplot(uk_countries) + geom_sf())
os_openmap_pow <- st_read(here("data", "os_openmap_pow.gpkg"), quiet = TRUE) os_openmap_pow <- st_read(here("data", "os_openmap_pow.gpkg"), quiet = TRUE)
bench_time(ggplot(os_openmap_pow) + geom_sf()) ggplot(os_openmap_pow) + geom_sf()
``` ```
It's worth noting that the way that you load geospatial data in R has changed quite dramatically since 2020 with the introduction of the simplefeature class in R. Much of the documentation you will come across "out there" will make reference to a set of functions which are now deprecated. It's worth noting that the way that you load geospatial data in R has changed quite dramatically since 2020 with the introduction of the simplefeature class in R. Much of the documentation you will come across "out there" will make reference to a set of functions which are now deprecated.

View file

@ -1,39 +1,39 @@
# Introduction: Hacking Religion # Introduction: Hacking Religion {.unnumbered}
## Who this book is for
## Why this book? ## Why this book?
Data science is quickly consolidating as a new field, with new tools and user communities emerging seemingly every week! At the same time the field of academic research has opened up into new interdisciplinary vistas, with experts crossing over into new fields, transgressing disciplinary boundaries and deploying tools in new and unexpected ways to develop knowledge. There are many gaps yet to be filled, but one which I found to be particularly glaring is the lack of applied data science documentation around the subject of religion. On one hand, scholars who are working with cutting edge theory seldom pick up the emerging tools of data science. On the other hand, data scientists rarely go beyond dabbling in religious themes. This book aims to bring these two things together: introducing the tools of data science in an applied way, whilst introducing some of the complexities and cutting edge theories which help us to conceptualise and frame our understanding of this knowledge.
## The hacker way ## The hacker way
1. Tell the truth It's worth emphasising at the outset that this isn't meant to be a generic data science book. My own training as a researcher lies in the field of religious ethics, and my engagement with digital technology has, from the very start, been a context for exploring matters of personal values, and social action. A fair bit of ink has been spilled in books, magazines, blogs, zines, and tweets unpacking what exactly it means to be a "hacker". Pressing beyond some of the more superficial cultural stereotypes, I want to explain a bit here about how hacking can be a much more substantial vision for ethical engagement with technology and social transformation.
2. Do not deceive using beauty Back in the 1980s Steven Levy tried to capture some of this in his book "Hackers: Heroes of the Computer Revolution". As Levy put it, the "hacker ethic" included: (1) sharing, (2) openness, (3) decentralisation, (4) free access to computers and (5) world improvement. The key point here is that hacking isn't just about writing and breaking code, or testing and finding weaknesses in computer systems and networks. It can be a more substantial ethical code.
3. Work transparently: research as open code using open data This emphasis on ethics is especially important when we're doing data science because this kind of research work will put you in positions of influence and grant you power over others. You might think this seems a bit overstated, but it never ceases to amaze me how much bringing a bar chart which succinctly shows some sort of social trend can sway a conversation or decision making process. There is something unusually persuasive that comes with the combination of aesthetics, data and storytelling. I've met many people who have come to data science out of a desire to bring about social transformation in some sphere of life. People want to use technology and communication to make the world better. However, it's possible that this can quickly get out of hand. It's important to have a clear sense of what sorts of convictions guide your work in this field, a "hacker code" of sorts. With this in mind, I'd like to share with you my own set of principles:
4. Draw others in: produce reproducible research It never ceases to amaze me how often people think that, when they're working for something they think is important it is acceptable to conceal bad news or amplify good or compelling information beyond its real scope. There are always consequences, eventually. When people realise you've been misleading or manipulating them your platform and credibility will evaporate. Good work mixed with bad will all get tossed out. And sometimes, our convictions can lead us beyond our true apprehension of a situation.
5. Learn by doing Presenting through "facts" an argument can become unnaturally compelling. Wrapping those facts up in something that uses colour, line and shape in a way that is aesthetically pleasing, even beautiful, enhances this allure even further. As you take up the hacker way, it's vitally important that you always strive to tell the truth. This includes a willingness to acknowledge the limits of your information, and to share the whole set of information. The easiest way to do this is to work with visualation in a responsible way (I'll get into this a bit more in Chapter 1) and to open up your data and code to scrutiny. By allowing others to try, criticise, edit, and reappropriate your code and data in their own ways, you contribute to knowledge help to build up a community of accountability. The upside of this is that it's also a lot more fun and interesting to work alongside others.
Far too often, scholarly research (and theology) has been criticised for being disconnected from reality, making abstract pie-in-the-sky claims about how life should be lived. When exposed to the uncomfortable pressures of reality, these claims can crumble, or even turn sinister. One of the upsides of working with empirical research is that you have a chance to engage with the real world. For this reason, I love to do ethics in a way that arises - bottom-up - from real world experiences and relationships. There's also the potential that when we make choices based on reliable information drawn from everyday reality like this our policy and culture can be more resilient and accountable. This also works well with the hacker ethos of "learning by doing" and it's this approach that guides my approach in this book. This isn't just a book about data analysis, I'm proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that you'll gain access to a set of tools and a research philosophy which is much more powerful.
## Why programmatic data science? Here's a quick summary of these principles, which I'll return to periodically as we work through the coding and data in this book:
This isn't just a book about data analysis, I'm proposing an approach which might be thought of as research-as-code, where you write out instructions to execute the various steps of work. The upside of this is that other researchers can learn from your work, correct and build on it as part of the commons. It takes a bit more time to learn and set things up, but the upside is that you'll gain access to a set of tools and a research philosophy which is much more powerful. 1. Tell the truth: Be candid about your limits, use visualisation responsibly
2. Work transparently: Open data, open code
3. Work in community, draw others in by producing reproducible research
4. Work with reality, learn by doing
## Learning to code: my way ## Learning to code: my way
This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, or whatever, such that it was weeks before I got to actually *do* anything. I know some people, may prefer this approach, but I dramatically prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so it's not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices I've made and the way I've structured things. Each chapter focusses on a *problem* which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a "deep dive" when you feel like it. Otherwise, I'll take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice. This guide is a little different from other textbooks targetting learning to code. I remember when I was first starting out, I went through a fair few guides, and they all tended to spend about 200 pages on various theoretical bits, how you form an integer, or data structures, subroutines, the logical structure of algorithms or whatever. It was usuallyweeks of reading before I got to actually *do* anything. I know some people may prefer this approach, but I prefer a problem-focussed approach to learning. Give me something that is broken, or a problem to solve, which engages the things I want to figure out and the motivation for learning just comes much more naturally. And we know from research in cognitive science that these kinds of problem-focussed approaches can tend to faciliate faster learning and better retention, so it's not just my personal preference, but also justified! It will be helpful for you to be aware of this approach when you get into the book as it explains some of the editorial choices I've made and the way I've structured things. Each chapter focusses on a *problem* which is particularly salient for the use of data science to conduct research into religion. That problem will be my focal point, guiding choices of specific aspects of programming to introduce to you as we work our way around that data set and some of the crucial questions that arise in terms of how we handle it. If you find this approach unsatisfying, luckily there are a number of really terrific guides which lay things out slowly and methodically and I will explicitly signpost some of these along the way so that you can do a "deep dive" when you feel like it. Otherwise, I'll take an accelerated approach to this introduction to data science in R. I expect that you will identify adjacent resources and perhaps even come up with your own creative approaches along the way, which incidentally is how real data science tends to work in practice.
There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, I'd recommend that many readers will want to check out Hadley Wickham's "R For Data Science" book. I'll include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail. There are a range of terrific textbooks out there which cover all these elements in greater depth and more slowly. In particular, I'd recommend that many readers will want to check out Hadley Wickham's "R For Data Science" book. I'll include marginal notes in this guide pointing to sections of that book, and a few others which unpack the basic mechanics of R in more detail.
## Getting set up ## Getting set up
Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the "hacker way") they've made these tools freely available. This also means that you aren't restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. I'll make a few opinionated recommendations here based on my own preferences and experience, but it's really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools you've found that you want to share with others. Every single tool, programming language and data set we refer to in this book is free and open source. These tools have been produced by professionals and volunteers who are passionate about data science and research and want to share it with the world, and in order to do this (and following the "hacker way") they've made these tools freely available. This also means that you aren't restricted to a specific proprietary, expensive, or unavailable piece of software to do this work. I'll make a few opinionated recommendations here based on my own preferences and experience, but it's really up to your own style and approach. In fact, given that this is an open source textbook, you can even propose additions to this chapter explaining other tools you've found that you want to share with others.