Skip to content

Commit

Permalink
Merge pull request #62 from nhs-r-community/table-align
Browse files Browse the repository at this point in the history
Table align
  • Loading branch information
Lextuga007 authored Mar 7, 2024
2 parents 2d3ee77 + c098f44 commit 868b8ef
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 91 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,19 @@ The aim of the project is to collect together information that is helpful and re

## Who is the audience?

The scope is very large, and analysts working in this space come from different types of organisation. For example:
The scope is very large, and analysts working in this space come from different types of organisations. For example:

- Provider trusts. Analysts with good access to patient-level data who can use their analyses to provide practical decision-support to people directly running services that patients use.

- Integrated Care Boards (ICBs). Analysts with less access to patient-level data, but with access to information from multiple organisations in a region, and with more context about regional populations, links to public health organisations, and local government.

- NHS "centre". Analysts from NHS Regions or NHS England who work with government on broad health inequalities intervention planning (for example those working on the [Core20PLUS5](https://www.england.nhs.uk/about/equality/equality-hub/national-healthcare-inequalities-improvement-programme/core20plus5/) programme).

The project is organic, and will be taken in the direction that contributors (with some steering from maintainers) choose. For example, if the majority of contributors are from provider trusts, it can be expected that the depth of information relevant to ICBs might be less deep.
- Public Health analysts. Analysts who may be working in Local Authorities or in Government Civil Service bodies who work with Public Health data.

**This is a call to action for contributors to involve themselves in the project! Please get involved if you work in this space, can see a gap, or want to steer the direction of this project.**

## Related projects
The project is organic, and will be taken in the direction that contributors. Some of the information may be relevant to only certain areas but one of the issues we face, as analysts, new and old is that this information is hidden. It may be that one area does something different but sharing this can influence how others collect and analyse their data.

This project has complementary R package projects, which are also open to contribution:

| Name | Purpose | Link |
|-------------------|-----------------------------|------------------------|
| {NHSRpopulation} | An R package to access the Index of Multiple Deprivation API. | https://nhs-r-community.github.io/NHSRpopulation/ |
| {NHSRpostcodetools} | This is a package of useful functions related to working with Postcodes within (currently) England using the [postcodes.io](https://postcodes.io/), an API to [Open Geography Portal](https://geoportal.statistics.gov.uk/datasets/postcode-to-output-area-to-lower-layer-super-output-area-to-middle-layer-super-output-area-to-local-authority-district-november-2018-lookup-in-the-uk-3/about) maintained by the ONS (Office of National Statistics). | https://nhs-r-community.github.io/NHSRpostcodetools/ |
**This is a call to action for contributors to involve themselves in the project! Please get involved if you work in this space, can see a gap, or want to steer the direction of this project.**

## Contributing

Expand All @@ -50,3 +43,11 @@ This book can receive comments via [giscus](https://giscus.app/) which is availa
Each page can also receive notations through [hypothes.is](https://web.hypothes.is/about/) and this can be found at the top right of every page. It is an overlay so can be seen even when you scroll down the page. To comment you will need to sign in to a hypothes.is account.

Details on how these have been used in the Quarto book can be found through the [Quarto documentation](https://quarto.org/docs/reference/projects/books.html#comments).

## Related projects

This project has complementary R package projects within NHS-R Community, which are also open to contribution:

[{NHSRpopulation}](https://nhs-r-community.github.io/NHSRpopulation/ "Link to the {NHSRpopulation} package website") - An R package to access the Index of Multiple Deprivation API.

[{NHSRpostcodetools}](https://nhs-r-community.github.io/NHSRpostcodetools/ "Link to {NHSRpostcodetools} package website") - This is a package of useful functions related to working with Postcodes.
69 changes: 36 additions & 33 deletions _book/imd.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ <h3 data-number="8.0.2" class="anchored" data-anchor-id="quintiles-in-r"><span c
<pre><code>Warning: package 'readr' was built under R version 4.3.2</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Warning: package 'dplyr' was built under R version 4.3.2</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Warning: package 'stringr' was built under R version 4.3.2</code></pre>
</div>
<div class="cell-output cell-output-stderr">
Expand All @@ -351,17 +354,17 @@ <h3 data-number="8.0.2" class="anchored" data-anchor-id="quintiles-in-r"><span c
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (&lt;http://conflicted.r-lib.org/&gt;) to force all conflicts to become errors</code></pre>
</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"># Generate a dataset</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> <span class="fu">structure</span>(<span class="fu">list</span>(<span class="at">IMDDecile =</span> <span class="fu">c</span>(<span class="dv">0</span>L, <span class="dv">1</span>L, <span class="dv">2</span>L, <span class="dv">3</span>L, <span class="dv">4</span>L, <span class="dv">5</span>L, <span class="dv">6</span>L, <span class="dv">7</span>L, </span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="dv">8</span>L, <span class="dv">9</span>L, <span class="dv">10</span>L, <span class="cn">NA</span>)), <span class="at">row.names =</span> <span class="fu">c</span>(<span class="cn">NA</span>, <span class="sc">-</span><span class="dv">12</span>L), <span class="at">class =</span> <span class="fu">c</span>(<span class="st">"tbl_df"</span>, </span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="st">"tbl"</span>, <span class="st">"data.frame"</span>))</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Make the 0 generated into NA</span></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a>data <span class="sc">|&gt;</span> </span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">replace_na</span>(<span class="fu">list</span>(<span class="at">IMDDecile =</span> <span class="dv">0</span>)) <span class="sc">|&gt;</span> </span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">IMDQuintile =</span> <span class="fu">floor</span>((IMDDecile<span class="dv">-1</span>)<span class="sc">/</span><span class="dv">2</span>) <span class="sc">+</span> <span class="dv">1</span>,</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> <span class="at">IMDQuintile =</span> <span class="fu">as.character</span>(IMDQuintile)</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> )</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate a dataset</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> <span class="fu">structure</span>(<span class="fu">list</span>(<span class="at">IMDDecile =</span> <span class="fu">c</span>(<span class="dv">0</span>L, <span class="dv">1</span>L, <span class="dv">2</span>L, <span class="dv">3</span>L, <span class="dv">4</span>L, <span class="dv">5</span>L, <span class="dv">6</span>L, <span class="dv">7</span>L, </span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="dv">8</span>L, <span class="dv">9</span>L, <span class="dv">10</span>L, <span class="cn">NA</span>)), <span class="at">row.names =</span> <span class="fu">c</span>(<span class="cn">NA</span>, <span class="sc">-</span><span class="dv">12</span>L), <span class="at">class =</span> <span class="fu">c</span>(<span class="st">"tbl_df"</span>, </span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="st">"tbl"</span>, <span class="st">"data.frame"</span>))</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Make the 0 generated into NA</span></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a>data <span class="sc">|&gt;</span> </span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">replace_na</span>(<span class="fu">list</span>(<span class="at">IMDDecile =</span> <span class="dv">0</span>)) <span class="sc">|&gt;</span> </span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">IMDQuintile =</span> <span class="fu">floor</span>((IMDDecile<span class="dv">-1</span>)<span class="sc">/</span><span class="dv">2</span>) <span class="sc">+</span> <span class="dv">1</span>,</span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> <span class="at">IMDQuintile =</span> <span class="fu">as.character</span>(IMDQuintile)</span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> )</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">
<pre><code># A tibble: 12 × 2
IMDDecile IMDQuintile
Expand Down Expand Up @@ -392,28 +395,28 @@ <h2 data-number="9.1" class="anchored" data-anchor-id="local-imd-creation-in-sql
<section id="local-imd-creation-in-r" class="level2" data-number="9.2">
<h2 data-number="9.2" class="anchored" data-anchor-id="local-imd-creation-in-r"><span class="header-section-number">9.2</span> Local IMD creation in R</h2>
<div class="cell">
<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="fu">library</span>(tidyverse)</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(PostcodesioR)</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(NHSRpostcodetools) <span class="co"># installed from GitHub not CRAN</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(NHSRpopulation)</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(janitor)</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate random example postcodes</span></span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a>postcodes <span class="ot">&lt;-</span> purrr<span class="sc">::</span><span class="fu">map_chr</span>(</span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a> <span class="dv">1</span><span class="sc">:</span><span class="dv">10</span>,</span>
<span id="cb13-10"><a href="#cb13-10" aria-hidden="true" tabindex="-1"></a> <span class="at">.f =</span> <span class="sc">~</span>PostcodesioR<span class="sc">::</span><span class="fu">random_postcode</span>() <span class="sc">|&gt;</span> </span>
<span id="cb13-11"><a href="#cb13-11" aria-hidden="true" tabindex="-1"></a> purrr<span class="sc">::</span><span class="fu">pluck</span>(<span class="dv">1</span>) </span>
<span id="cb13-12"><a href="#cb13-12" aria-hidden="true" tabindex="-1"></a>) <span class="sc">|&gt;</span> </span>
<span id="cb13-13"><a href="#cb13-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">as_tibble</span>()</span>
<span id="cb13-14"><a href="#cb13-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-15"><a href="#cb13-15" aria-hidden="true" tabindex="-1"></a>pc_imd <span class="ot">&lt;-</span> NHSRpostcodetools<span class="sc">::</span><span class="fu">postcode_data_join</span>(<span class="at">.data =</span> postcodes<span class="sc">$</span>value) <span class="sc">|&gt;</span> </span>
<span id="cb13-16"><a href="#cb13-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(postcode,</span>
<span id="cb13-17"><a href="#cb13-17" aria-hidden="true" tabindex="-1"></a> lsoa_code) <span class="sc">|&gt;</span> </span>
<span id="cb13-18"><a href="#cb13-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">left_join</span>(NHSRpopulation<span class="sc">::</span>imd <span class="sc">|&gt;</span> </span>
<span id="cb13-19"><a href="#cb13-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(lsoa_code,</span>
<span id="cb13-20"><a href="#cb13-20" aria-hidden="true" tabindex="-1"></a> imd_score,</span>
<span id="cb13-21"><a href="#cb13-21" aria-hidden="true" tabindex="-1"></a> imd_decile), <span class="fu">join_by</span>(lsoa_code <span class="sc">==</span> lsoa_code)) <span class="sc">|&gt;</span> </span>
<span id="cb13-22"><a href="#cb13-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">imd_decile_local =</span> <span class="fu">ntile</span>(<span class="sc">-</span>imd_score, <span class="at">n =</span> <span class="dv">10</span>)) <span class="co"># creating new deciles from the data provided</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<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="fu">library</span>(tidyverse)</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(PostcodesioR)</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(NHSRpostcodetools) <span class="co"># installed from GitHub not CRAN</span></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(NHSRpopulation)</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(janitor)</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate random example postcodes</span></span>
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a>postcodes <span class="ot">&lt;-</span> purrr<span class="sc">::</span><span class="fu">map_chr</span>(</span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a> <span class="dv">1</span><span class="sc">:</span><span class="dv">10</span>,</span>
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a> <span class="at">.f =</span> <span class="sc">~</span>PostcodesioR<span class="sc">::</span><span class="fu">random_postcode</span>() <span class="sc">|&gt;</span> </span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a> purrr<span class="sc">::</span><span class="fu">pluck</span>(<span class="dv">1</span>) </span>
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a>) <span class="sc">|&gt;</span> </span>
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">as_tibble</span>()</span>
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a>pc_imd <span class="ot">&lt;-</span> NHSRpostcodetools<span class="sc">::</span><span class="fu">postcode_data_join</span>(<span class="at">.data =</span> postcodes<span class="sc">$</span>value) <span class="sc">|&gt;</span> </span>
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(postcode,</span>
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a> lsoa_code) <span class="sc">|&gt;</span> </span>
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">left_join</span>(NHSRpopulation<span class="sc">::</span>imd <span class="sc">|&gt;</span> </span>
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(lsoa_code,</span>
<span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a> imd_score,</span>
<span id="cb14-21"><a href="#cb14-21" aria-hidden="true" tabindex="-1"></a> imd_decile), <span class="fu">join_by</span>(lsoa_code <span class="sc">==</span> lsoa_code)) <span class="sc">|&gt;</span> </span>
<span id="cb14-22"><a href="#cb14-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">imd_decile_local =</span> <span class="fu">ntile</span>(<span class="sc">-</span>imd_score, <span class="at">n =</span> <span class="dv">10</span>)) <span class="co"># creating new deciles from the data provided</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
</section>
Expand Down
Loading

0 comments on commit 868b8ef

Please sign in to comment.