You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blogs/posts/2024-08-08_map-and-nest/index.qmd
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ library(snakecase)
22
22
23
23
I want to share a framework that I like using occasionally for data analysis. It's the nest-and-map and it's helped me countless times when I'm working with related datasets. By combining [{purrr}](https://purrr.tidyverse.org/) mapping with [{tidyr}](https://tidyr.tidyverse.org/) nesting, I can keep my analysis steps linked, allowing me to easily track from a summary or plot, back to the original data.
24
24
25
-
The main funtions we'll need are
25
+
The main functions we'll need are
26
26
27
27
-`tidyr::nest()`
28
28
-`dplyr::mutate()`
@@ -99,7 +99,7 @@ I've created two functions, `plot_barchart()` and `plot_waffle()` which take the
99
99
<summary>See definition for `plot_barchart()` & `plot_waffle()`</summary>
100
100
```{r}
101
101
#' Plot barchart
102
-
#' Makes a bar chart of staff perentages by organisation
102
+
#' Makes a bar chart of staff percentages by organisation
103
103
#' @param df tibble of staff data in percent format
Again, using `mutate()` I can create a new column called `barchart` and I can `map()` the function `plot_barchart()`, applying it to each row at a time.
142
+
Again, using `mutate()` I can create a new column called `barchart` and I can `map()` the function `plot_barchart()`, applying it to each row at a time.
143
143
144
144
```{r}
145
145
graphs <-
@@ -163,7 +163,7 @@ processed_staff |>
163
163
)
164
164
```
165
165
166
-

166
+
{fig-alt="A horizontally placed bar chart example with categories for Ambulance staff, Doctors, Midwives and Nurses as specific bars across sections for 7 Hospital and Ambulance Trusts"}
167
167
168
168
## Putting it all together
169
169
@@ -197,4 +197,4 @@ purrr::walk2(
197
197
```
198
198
199
199
By keeping everything together in one nested structure, I personally find it much easier to keep track of my analyses.
200
-
If you're doing a more complex or permenant analysis, you might want to consider setting up a more formal data processing pipeline, and following RAP principals.
200
+
If you're doing a more complex or permanent analysis, you might want to consider setting up a more formal data processing pipeline, and following RAP principals.
Copy file name to clipboardExpand all lines: blogs/posts/2024-11-29-mapping-my-r-learning/index.qmd
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ A couple of years later, when I started my current job, I heard about the NHS-R
21
21
22
22
It seemed important to try and change my approach, so that learning R didn't seem so daunting. I came across the [aRtsy](https://cran.r-project.org/web/packages/aRtsy/readme/README.html) package and was amazed by the colourful and intricate artwork that it could produce. But better still, all of the code was open-source. I experimented with the code, making very small changes to see what kind of images it would create.
23
23
24
-
 package and the [canvas_nebula](https://koenderks.github.io/aRtsy/#nebula) function](Nebula.jpg)
24
+
 package and the [canvas_nebula](https://koenderks.github.io/aRtsy/#nebula){fig.alt="An abstract art piece with shades of blue colour that give it an almost organic or cloud appearance"} function](Nebula.jpg)
25
25
26
26
I also discovered colour palettes such as those in the [wesanderson](https://github.com/karthik/wesanderson) package, and tried experimenting with those along with the generative art functions. I soon found that my fear of R was quickly replaced by a geeky fascination with all of the beautiful artwork that could be created with only a few lines of code. It felt like a low-stakes situation, because the worst that could happen was that the code wouldn't work. Suddenly, the process of coding felt less intimidating, and it had opened up a wealth of possibilities[^1].
27
27
@@ -57,7 +57,7 @@ Over time I understood that failure is part of the learning journey, and a helpf
57
57
58
58
As well as providing some humour to contrast with the often frustrating process of learning to code, these failures also helped me to get unstuck. More often than not, they were a catalyst for problem-solving as they provided useful information about what specific aspect of the code had gone wrong, which would give me a clue about what I needed to look into to fix the problem.
59
59
60
-
{fig-align="center"}
60
+
{fig-alt="A chart with axes latitude and logitude that has been stretched so the chart itself is just a centimetre or so across but many centimetres from top to bottom. A very small country shaped blob can be seen at the very top and to the side of the chart the population density 2021 key is more clearly viewable." fig-align="center"}
61
61
62
62
8.**I looked for inspiration to encourage me to keep going**
63
63
@@ -71,9 +71,9 @@ Throughout my R learning journey, I have found that coding has been a useful con
71
71
72
72
I realised this a few months ago when my friend got me a beginner's embroidery kit, and as I followed the pattern and learned how to create the different types of embroidery stitch, I reflected that just like with the embroidery pattern I was working on, I needed to structure the coding for the map in [layers](https://ggplot2.tidyverse.org/reference/layer_geoms.html#:~:text=In%20ggplot2%2C%20a%20plot%20in,displayed%2C%20not%20what%20is%20displayed.). This led me to approach the process like I would for an art project[^4] to identify what I needed to do to adequately visualise both types of data that I wanted to include in the map.
73
73
74
-
[^4]: Throughout the journey I have realised that thinking about the problem like an artist has been very helpful, because it allows me to use a similarly iterative approach. I wanted my choropleth maps to show both the population density and the underlying terrain when superimposed. To do this, I used the [colorbrewer2](https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3) tool to test out different colour palettes, and changed the opacity and terrain to identify which colours would clearly to show the population data and the terrain underneath. The tool let me test this on an example map and showed me the hexadecimal colour codes for the colours in the palettes. Once I had found some combinations that would likely work for my particular map, I then iteratively adjusted the aesthetics in my R code until I found a combination that worked for my data.
74
+
[^4]: Throughout the journey I have realised that thinking about the problem like an artist has been very helpful, because it allows me to use a similarly iterative approach. I wanted my choropleth maps to show both the population density and the underlying terrain when superimposed. To do this, I used the [colorbrewer2](https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3) tool to test out different colour palettes, and changed the opacity and terrain to identify which colours would clearly to show the population data and the terrain underneath. The tool let me test this on an example map and showed me the hexadecimal colour codes for the colours in the palettes. Once I had found some combinations that would likely work for my particular map, I then iteratively adjusted the aesthetics in my R code until I found a combination that worked for my data.
75
75
76
-
{fig-alt="Textile art piece showing a map with the letter R - for decorative purposes only" fig-align="center" width="384"}
76
+
{fig-alt="Textile art piece showing a map with the letter R - for decorative purposes only" fig-align="center" width="384"}
77
77
78
78
10.**I started learning about how to stay involved in the community**
Copy file name to clipboardExpand all lines: blogs/posts/2024-12-04-gha-branch-preview/index.qmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ Once the site has rendered, we just need to add a step to deploy the PR.
106
106
107
107
Now everytime a PR is created, or updated, the GitHub Action bot will spring into action.
108
108
109
-
\
109
+
{fig-alt="Screenshot of a conversation from GitHub with a GitHub action for the preview."}
Copy file name to clipboardExpand all lines: blogs/posts/2025-05-06_NLP-hackathon/index.qmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ We decided to use some data from a recent survey, which needed to be categorised
31
31
32
32
Our mission was to develop a model to help the Evaluation team categorise responses quickly, with a reasonable degree of performance.
33
33
34
-

34
+
{fig.alt="Film image of actor hanging from the ceiling with his legs higher than his head. He is facing a computer terminal which he is poised at a keyboard typing."}
Copy file name to clipboardExpand all lines: blogs/posts/2025-05-16 data-science-as-a-product/index.qmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ execute:
14
14
enabled: false
15
15
---
16
16
17
-

17
+
{fig.alt="Image of part of a person in view in a white coat with stethoscope with a pen in one hand which is poised over document on a clip pad of a bar chart. The person is holding a 3D bar chart type model in the other hand."}
18
18
19
19
Data science in healthcare is booming.
20
20
Every day new advances emerge that promise to deepen understanding, improve screening or optimise treatments.
Copy file name to clipboardExpand all lines: blogs/posts/2025-09-18_verifying_git_commits/index.qmd
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ format:
23
23
Ever looked at a list of commits on GitHub and noticed ✅ green checks next to some commits, but not others?
24
24
Wondered what they mean?
25
25
26
-

26
+
{fig.alt="Screenshot of the Commit history view of GitHub with examples of both verified commits and unverified commits by the same person." width="100%"}
27
27
28
28
Here’s a screenshot of our [nhp_inputs](https://github.com/The-Strategy-Unit/nhp_inputs/commits/main/) repository.
29
29
You can see that some commits (merge commits, specifically here) have those checks, while others don’t.
@@ -45,7 +45,7 @@ This isn’t just a GitHub feature; it’s built directly into Git.
45
45
46
46
Below is a screenshot of our [nhp_model](https://github.com/the-strategy-unit/nhp_model/commits/main), where all the commits I’ve authored have been signed with [my GPG key](https://keyserver.ubuntu.com/pks/lookup?search=8F3C2735D62D6993&fingerprint=on&op=index).
47
47
48
-

48
+
{fig.alt="Screenshot of the Git commit history which are all verified and also a tool tip box showing details of the verification details: who did the commit and the GPG key along with verification date." width="100%"}
49
49
50
50
Setting up GPG can be a bit of a faff, but there’s an easier way: using SSH keys to sign commits.
51
51
You may already have SSH set up for pushing and pulling from GitHub, so this is a no-brainer.
Copy file name to clipboardExpand all lines: blogs/posts/2025-11-07_pandas_vs_polars/index.qmd
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,9 @@ Polars has been frequently discussed as a possible improvement over Pandas. With
30
30
In this article, we'll share our experience reimplementing one of our core data processing modules from Pandas to Polars, including the challenges we faced, the benefits we've seen, and lessons learned along the way. You can find our [nhp_products](https://github.com/The-Strategy-Unit/nhp_products) code on GitHub. We've kept both implementations for comparison, with polars modules bearing a `_pl.py` suffix.
{height="200px"}{fig.alt="Two polar bear cubs playing in the snow, one goes up to the other, grabs it in a bite and they both slide down the snow turning over onto their backs." width="100%"}
36
36
:::
37
37
38
38
## Background: The Detailed Results Processing Challenge
0 commit comments