Publications by Gary Hutson

Diverging Bar Charts – Plotting Variance with ggplot2

16.05.2018

Diverging Bar Charts The aim here is to create a diverging bar chart that shows variance above and below an average line. In this example I will use Z Scores to calculate the variance, in terms of standard deviations, as a diverging bar. This example will use the mtcars stock dataset, as most of the data I deal with day-to-day is patient sensit...

4078 sym R (1447 sym/9 pcs) 2 img

Diverging Dot Plot and Lollipop Charts – Plotting Variance with ggplot2

16.05.2018

Creating the Dot Plot Variance chart The data preparation was used in the previous blog entitled: Diverging Bar Charts – Plotting Variance with ggplot2. Refer to that if you need to know how to create the data prior to this tutorial. Setting up the Dot Plot Variance chart library(ggplot2) ggplot(mtcars, aes(x=CarBrand, y=mpg_z_score, label=mp...

2216 sym R (1314 sym/2 pcs) 4 img

Histogram with auto binning in ggplot2

16.05.2018

Histograms (with auto binning) Again, we will use the mtcars dataset and use the fields in that to produce the chart, as we are doing this there is nothing to do on the data preparation side. That leaves us to have fun with the plot. Building the Histogram with auto binning I set up the plot, as per below: library(ggplot2) theme_set(theme_classic...

1880 sym R (597 sym/4 pcs) 4 img

Box Plots in ggplot2

16.05.2018

Setting up the plot The box plot, in ggplot2, can be really powerful and useful for analysing variation. I will show a few examples of different types of box plots in ggplot2. Basic Box Plot library(ggplot2) theme_set(theme_classic()) # Plot plot <- ggplot(mpg, aes(class, cty)) plot + geom_boxplot(varwidth=T, fill="grey") + labs(title="Box plot...

2017 sym R (1035 sym/3 pcs) 6 img

Violin and density plots in ggplot2

17.05.2018

Violin Plots This chart is a combination of a Box Plot and a Density Plo that is rotated and placed on each side, to show the distribution shape of the data. The thick black bar in the centre represents the interquartile range, the thin black line extended from it represents the 95% confidence intervals, and the white dot is the median. The ...

4064 sym R (1172 sym/5 pcs) 12 img

DPLYR: A Beginners Guide

24.05.2018

What is DPLYR? Dplyr is a grammar of data manipulation, providing a consistent set of verbs that help you solve the most common data manipulation challenges. The next series of examples will show how you can use the shortcuts in Dplyr to achieve the results of traditional R data manipulation, but faster. Setting dplyr up in your R environment To...

6855 sym R (1270 sym/14 pcs) 18 img

A simple function to install and load packages in R

16.08.2018

One function to rule the world, or install or load your packages for you I was starting to despair at the amount of packages I end up using during the task of transforming, cleaning, modelling and validating some of my models. I thought there must be a simple approach to dealing with this? So, I started to ponder if I could create a function that...

2004 sym R (476 sym/2 pcs) 2 img

A simple function to create nice correlation plots

30.11.2018

The problem I was working with a dataset where I wanted to assess the correlation of different variables in R. As much as I like R – the outputs from the console window leave something to be desired (in terms of data visualisation). Therefore, I wanted a way to visualise these correlations in a nicer / cleaner / crisper way. The solution to thi...

5911 sym R (1817 sym/5 pcs) 2 img

NHS-R Community: Up the R-evolution

29.01.2019

It seems like two seconds ago since I was frantically preparing slides for the first NHS community. Wow – what an experience and kudos to the team @NHS-R Community for arranging it. The full content of the event has been posted: https://nhsrcommunity.com/nhs-r-conference-9-october-2018/. What a fantastic event this was and I met many of my fe...

2711 sym

Outpatient scatter charts: Analysing new and follow up activity with gganimate

30.01.2019

I was inspired by my friend John Mackintosh to have a muck around with the fabulous gganimate. I have to say…. I am in love. I can remember coding this into Excel VBA, to get my animations to work on my data, and now R has the potential. John will remind me that it has been available for a while, but it is new to me. Setting up the random dat...

3110 sym R (1959 sym/5 pcs) 8 img