Six Months Later

Graphic by Carl Goodwin

In September 2017 I wrote a post entitled Let’s Jitter. It looked at how the SME share of sales evolved over time. I revisited this topic here six months later, along the way adding a splash of colour and some faceted plots.

I’m using one of the beautiful range of Wes Anderson Palettes. I often use the palettes provided by ColorBrewer too.

theme_set(theme_bw())

(cols <- wes_palette(9, name = "Chevalier1", type = "continuous"))

In Let’s Jitter I assumed the G-Cloud data file adopted the UK Government standard of UTF-8. I used the stringr package to fix any issues.

This time around, I’m importing the files for two frameworks (G-Cloud and DOS) after first checking the encoding to see if I can get a cleaner import. guess_encoding suggests these files use the ISO-8859-1 standard.

gcloud_csv <- 
  "https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/678283/G-Cloud-spend-Dec2017.csv"

dos_csv <- 
  "https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/678286/DOS-spend-Dec2017.csv"

names <- c(gcloud_csv, dos_csv)

map(names, guess_encoding)
## [[1]]
## # A tibble: 2 x 2
##   encoding   confidence
##   <chr>           <dbl>
## 1 ISO-8859-1       0.39
## 2 ISO-8859-2       0.24
## 
## [[2]]
## # A tibble: 2 x 2
##   encoding   confidence
##   <chr>           <dbl>
## 1 ISO-8859-1       0.44
## 2 ISO-8859-2       0.23

Next I’ll set up a vector of column names to apply consistently to both files, import the data with the suggested encoding, and bind them into one tibble.

colnam <- 
  c("sector", "lot", "month", "spend", "status", "supplier", "customer", "framework")

read_dm <- function(x){
  read_csv(
    x,
    col_names = colnam,
    skip = 1,
    locale(encoding = "ISO-8859-1"),
    col_types = NULL)
}

both <- map(names, read_dm) %>% 
  set_names(c("gcloud", "dos")) %>% 
  bind_rows() %>% 
  mutate(framework = if_else(is.na(framework), "DOS", framework))

I’d like to create some new features: Month-end dates, something to distinguish between the two frameworks (G-Cloud or DOS) and the framework version (i.e. G-Cloud 1 to 9). The spend has a messy format and needs a bit of cleaning too.

both <- both %>%
  mutate(
    month_start = myd(str_c(month, "-01")),
    month_end = month_start + months(1) - 1,
    version = str_remove(framework, fixed("-Cloud ")),
    version = str_replace(version, fixed("G-Cloud"), "G1"),
    version = str_replace(version, fixed("GIII"), "G3"),
    version = str_replace(version, fixed("GServices II"), "G2"),
    framework = str_extract(framework, ".{3,7}"),
    spend = str_remove(spend, fixed("£")),
    spend = str_replace(spend, "^\\(", "-"),
    spend = parse_number(spend),
    SME_spend = if_else(status == "SME", spend, 0)
  )

Finding the interval between G-Cloud versions will enable me to calculate and print the average in the next paragraph using inline r code.

version <- both %>%
  filter(version != "DOS") %>% 
  group_by(version) %>%
  summarise(start = min(month_end)) %>% 
  mutate(next_start = lead(start)) %>% 
  mutate(interval = lubridate::interval(start, next_start) %/% months(1))

Every 8 months, on average, suppliers are asked to resubmit their G-Cloud offerings with their latest pricing and service descriptions. It’s a chance for new suppliers, often smaller ones, to join the existing list of suppliers and increase overall competitiveness for Cloud services.

Let’s visualise how each of these framework versions grows, matures and fades away as the next one takes over.

vers_summary <- both %>%
  filter(version != "DOS") %>% 
  group_by(version, month_end) %>%
  summarise(sales = sum(spend) / 1000000)

ggplot(vers_summary, aes(month_end, sales, colour = version)) +
  geom_line() +
  geom_smooth(size = 2) +
  scale_x_date(date_breaks = "years", date_labels = "%Y") +
  scale_colour_manual(values = cols) +
  labs(x = NULL, y = NULL, title = "The Lifecycle of G-Cloud Versions", 
       subtitle = "Monthly £m Sales by Version") + 
  labs(caption = "\nSource: GOV.UK's Digital Marketplace")

Let’s Jitter showed signs of a weakening in the SME share of G-Cloud sales by value. This plot shows this trend to have persisted, and also reflects the Digital Outcomes & Specialists (DOS) framework exhibiting a downward trend.

fw_summary <- both %>%
  group_by(framework, month_end) %>%
  summarise(pct = sum(SME_spend, na.rm = TRUE) / sum(spend, na.rm = TRUE))

ggplot(fw_summary, aes(month_end, pct, colour = framework)) +
  geom_line() +
  geom_smooth(size = 2) +
  scale_y_continuous(breaks = c(0.25, 0.5, 0.75, 1), labels = percent_format()) +
  scale_x_date(date_breaks = "years", date_labels = "%Y") +
  scale_colour_manual(values = cols[c(1, 9)]) +
  labs(x = NULL, y = NULL, title = "The Waning SME Share of Sales", 
       subtitle = "% Monthly Sales Value via SME (vs Large Enterprise) Suppliers") + 
  labs(caption = "\nSource: GOV.UK's Digital Marketplace")

Overall spending via the combined frameworks however continues to grow across all parts of Public Sector. I’ll use a small multiples visualisation technique to show this using ggplot2’s facet_wrap.

sect_summary <- both %>%
  filter(!sector %in% c("Unregistered or Unknown",
                        "Utility (Historic)",
                        "Wider Public Sector")) %>%
  group_by(sector, month_end) %>%
  summarise(
  sales = sum(spend) / 1000000,
  pct = sum(SME_spend, na.rm = TRUE) / sum(spend, na.rm = TRUE)
  )

ggplot(sect_summary, aes(month_end, sales, colour = sector)) +
  geom_line() +
  geom_smooth(size = 2) +
  facet_wrap(~ sector, scales = "free_y") +
  theme(legend.position = "none") +
  scale_x_date(date_breaks = "years", date_labels = "%Y") +
  scale_colour_manual(values = cols) +
  labs(x = NULL, y = NULL, 
       title = "All Sectors Increase Digital Marketplace Spend", 
       subtitle = "£m G-Cloud & DOS Spend by Sector") + 
  labs(caption = "\nSource: GOV.UK's Digital Marketplace")

The decline in the proportion of spend via SMEs is also fairly broad-based.

ggplot(sect_summary, aes(month_end, pct, colour = sector)) +
  geom_line() +
  geom_smooth(size = 2) +
  facet_wrap(~ sector, scales = "free_y") +
  theme(legend.position = "none") +
  scale_x_date(date_breaks = "years", date_labels = "%Y") +
  scale_colour_manual(values = cols) +
  labs(x = NULL, y = NULL, 
       title = "Most Sectors Spend Proportionately Less on SMEs", 
       subtitle = "% SME G-Cloud & DOS Spend by Sector") + 
  labs(caption = "\nSource: GOV.UK's Digital Marketplace")

R Toolbox

Summarising below the packages and functions used in this post enables me to separately create a toolbox visualisation summarising the usage of packages and functions across all posts.

Package Function
base sum[7]; library[6]; c[5]; function[2]; months[2]; conflicts[1]; cumsum[1]; is.na[1]; min[1]; search[1]
dplyr mutate[8]; filter[7]; group_by[5]; if_else[5]; summarise[5]; tibble[2]; arrange[1]; as_tibble[1]; bind_rows[1]; desc[1]; lead[1]; select[1]
ggplot2 labs[8]; aes[4]; geom_line[4]; geom_smooth[4]; ggplot[4]; scale_colour_manual[4]; scale_x_date[4]; facet_wrap[2]; theme[2]; scale_y_continuous[1]; theme_bw[1]; theme_set[1]
kableExtra kable_material[1]; kbl[1]
lubridate myd[1]
purrr map[3]; set_names[2]; map2_dfr[1]; possibly[1]
readr cols[3]; guess_encoding[1]; locale[1]; parse_number[1]; read_csv[1]; read_lines[1]
rebus literal[4]; lookahead[3]; whole_word[2]; ALPHA[1]; lookbehind[1]; one_or_more[1]; or[1]
scales percent_format[1]
stats start[1]
stringr fixed[5]; str_remove[4]; str_replace[4]; str_c[3]; str_detect[3]; str_count[1]; str_extract[1]; str_remove_all[1]
tibble enframe[1]
tidyr unnest[1]
wesanderson wes_palette[1]
Carl Goodwin
Carl Goodwin
IBM Data Scientist & Growth Strategy Leader
comments powered by Disqus

Related