Ph Profiles

[This article was first published on Data By John, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

why— layout: post title: That’s a (W)RAP! published: true date: 2023-12-06 image: path: /assets/img/blog/officer.png tags:

  • rstats description: > An ambition realised as a suite of R powered publications enter the public domain —

The third set in our series of public health profiles was published recently.
These comprise of a suite of 13 reports (representing community planning partnerships in Highland and community planning groups in Argyll and Bute).

So far, we have produced profiles looking at demography, adult health and wellbeing, and our latest – children and young people’s health and wellbeing.

Although distributed as pdf files, they were produced as MS Word documents using R, in particular using {officedown}, {officer}, {targets}, {tarchetypes} and {renv}. In addition to these were several ancillary packages and the usual suspects ( including dplyr, data.table, ggplot2, collapse, here, rio)

You can find the full set of public health profiles here.

In terms of the R code and approach, this has been an evolving piece of work.

The demography profiles were produced using a series of numbered scripts.
I adopted {targets} for the adult profiles, a decision which paid dividends many times over.

As I worked through the child profiles, I realised that the project was far too complex, because I was producing copies of every image and table, in addition to the reports. This meant huge (1000s of lines) targets documents for each profile.

This was in case there was ever a Friday afternoon emergency when someone needed 13 copies of Figure 5 from report 2.

Dear reader, this has never happened, and almost certainly never will. In any case, those images can be recreated easily as required, on demand, using purrr (if you haven’t fallen in love with the walk set of functions yet, then you are missing out).

I decided not to make copies of these images for the latest set of profiles, and, upon publication, I removed large swathes of code from the first two sets of targets files.

The benefit of this is that the simpler structure makes it easier for colleagues to follow and reproduce.

Other improvement this time round included us having to make far fewer edits “by hand” in the resulting Word outputs. Previous versions relied on my much more talented colleagues who took the mess I produced and turned it into something fit for public consumption.

We automated production of the summaries – before we had 13 individual documents, this time round the text adapted to reflect the data for the relevant area. I think we have scope to enhance this in the next round of production. Production of the charts was easier because I’d created an internal charting package (tentatively named {phicharts}) based on the code used for the adult profiles. I’d also revised a previous project, which turned data published in wide Excel tables into tidy RDS files, also under the management of the {targets} package. These files were also used as inputs to the most recent publication.

We are slowly move up the Reproducible Analytic Pipeline ladder (we need testing and version control, and to make our code public).

I always wondered if I’d be able to create a full blown publication from scratch using R, so getting it done, and having it made available on our main website feels like a big step forward.

Hopefully we will continue to progress on our journey with R.

To leave a comment for the author, please follow the link and comment on their blog: Data By John.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)