Urban Rural Plot

Introduction

A quick look at the newly published Urban/Rural classification data and a visualisation of the classification at Local Authority level.

I am using the population tables available at this link

Load packages

library(tidyverse)
library(magrittr)
library(readxl)
library(janitor)
library(ggthemr)
ggthemr("light", "plain")

Load data

pop_table <- read_xlsx("2018-03-29-urban-rural-plot_data/00534380.xlsx",
                       sheet = "CA8FOLD", range = "A3:I36")

Tidy up

Data is all good but I need to tidy up the variable names and factorise the local authority variable

pop_table <- clean_names(pop_table)

pop_table$council_area <- factor(pop_table$council_area)

I also want to make the table “tidy” and in long format for easier plotting

#gather
pop_table %<>% 
  gather(class, percent, large_urban:very_remote_rural)

#factorise class
pop_table$class <- factor(pop_table$class,
                          levels = c("large_urban", "other_urban",
                                     "accessible_small_towns",
                                     "remote_small_towns",
                                     "very_remote_small_towns",
                                     "accessible_rural",
                                     "remote_rural", "very_remote_rural"),
                          labels = c("Large urban", "Other urban",
                                     "Small town accessible",
                                     "Small town remote",
                                     "Small town very remote",
                                     "Rural accessible",
                                     "Rural remote", "Rural very remote")
)

Visualise

Ready to plot now. I am using the ggthemr package for themes. Only found it today and love how it creates such a professional finish so simply!!!

pop_table %>% 
  ggplot(aes(class, percent, fill = class)) +
  geom_col() +
  guides(fill = guide_legend(nrow = 1)) +
  facet_wrap(~council_area, strip.position = "bottom") +
  theme(
    axis.text.x = element_blank(),
    legend.position = "top"
  ) +
  labs(
    title = "Percentage of individuals living in urban/remote areas",
    subtitle = "Eight-fold classification",
    y = "%",
    x = "",
    fill = ""
  ) -> urbrur_plot
urbrur_plot

A very quick and simple summary but a nice plot in the end!

Session Info

devtools::session_info()
## Session info -------------------------------------------------------------
##  setting  value                       
##  version  R version 3.5.1 (2018-07-02)
##  system   x86_64, mingw32             
##  ui       RTerm                       
##  language (EN)                        
##  collate  English_United Kingdom.1252 
##  tz       Europe/London               
##  date     2018-10-02
## Packages -----------------------------------------------------------------
##  package    * version date       source                          
##  assertthat   0.2.0   2017-04-11 CRAN (R 3.5.1)                  
##  backports    1.1.2   2017-12-13 CRAN (R 3.5.0)                  
##  base       * 3.5.1   2018-07-02 local                           
##  bindr        0.1.1   2018-03-13 CRAN (R 3.5.1)                  
##  bindrcpp     0.2.2   2018-03-29 CRAN (R 3.5.1)                  
##  blogdown     0.8     2018-07-15 CRAN (R 3.5.1)                  
##  bookdown     0.7     2018-02-18 CRAN (R 3.5.1)                  
##  broom        0.5.0   2018-07-17 CRAN (R 3.5.1)                  
##  cellranger   1.1.0   2016-07-27 CRAN (R 3.5.1)                  
##  cli          1.0.0   2017-11-05 CRAN (R 3.5.1)                  
##  colorspace   1.3-2   2016-12-14 CRAN (R 3.5.1)                  
##  compiler     3.5.1   2018-07-02 local                           
##  crayon       1.3.4   2017-09-16 CRAN (R 3.5.1)                  
##  datasets   * 3.5.1   2018-07-02 local                           
##  devtools     1.13.6  2018-06-27 CRAN (R 3.5.1)                  
##  digest       0.6.17  2018-09-12 CRAN (R 3.5.1)                  
##  dplyr      * 0.7.6   2018-06-29 CRAN (R 3.5.1)                  
##  evaluate     0.11    2018-07-17 CRAN (R 3.5.1)                  
##  forcats    * 0.3.0   2018-02-19 CRAN (R 3.5.1)                  
##  ggplot2    * 3.0.0   2018-07-03 CRAN (R 3.5.1)                  
##  ggthemr    * 1.1.0   2018-10-02 Github (cttobin/ggthemr@0a31bb5)
##  glue         1.3.0   2018-07-17 CRAN (R 3.5.1)                  
##  graphics   * 3.5.1   2018-07-02 local                           
##  grDevices  * 3.5.1   2018-07-02 local                           
##  grid         3.5.1   2018-07-02 local                           
##  gtable       0.2.0   2016-02-26 CRAN (R 3.5.1)                  
##  haven        1.1.2   2018-06-27 CRAN (R 3.5.1)                  
##  hms          0.4.2   2018-03-10 CRAN (R 3.5.1)                  
##  htmltools    0.3.6   2017-04-28 CRAN (R 3.5.1)                  
##  httr         1.3.1   2017-08-20 CRAN (R 3.5.1)                  
##  janitor    * 1.1.1   2018-07-31 CRAN (R 3.5.1)                  
##  jsonlite     1.5     2017-06-01 CRAN (R 3.5.1)                  
##  knitr        1.20    2018-02-20 CRAN (R 3.5.1)                  
##  labeling     0.3     2014-08-23 CRAN (R 3.5.0)                  
##  lattice      0.20-35 2017-03-25 CRAN (R 3.5.1)                  
##  lazyeval     0.2.1   2017-10-29 CRAN (R 3.5.1)                  
##  lubridate    1.7.4   2018-04-11 CRAN (R 3.5.1)                  
##  magrittr   * 1.5     2014-11-22 CRAN (R 3.5.1)                  
##  memoise      1.1.0   2017-04-21 CRAN (R 3.5.1)                  
##  methods    * 3.5.1   2018-07-02 local                           
##  modelr       0.1.2   2018-05-11 CRAN (R 3.5.1)                  
##  munsell      0.5.0   2018-06-12 CRAN (R 3.5.1)                  
##  nlme         3.1-137 2018-04-07 CRAN (R 3.5.1)                  
##  pillar       1.3.0   2018-07-14 CRAN (R 3.5.1)                  
##  pkgconfig    2.0.2   2018-08-16 CRAN (R 3.5.1)                  
##  plyr         1.8.4   2016-06-08 CRAN (R 3.5.1)                  
##  purrr      * 0.2.5   2018-05-29 CRAN (R 3.5.1)                  
##  R6           2.2.2   2017-06-17 CRAN (R 3.5.1)                  
##  Rcpp         0.12.18 2018-07-23 CRAN (R 3.5.1)                  
##  readr      * 1.1.1   2017-05-16 CRAN (R 3.5.1)                  
##  readxl     * 1.1.0   2018-04-20 CRAN (R 3.5.1)                  
##  rematch      1.0.1   2016-04-21 CRAN (R 3.5.1)                  
##  rlang        0.2.2   2018-08-16 CRAN (R 3.5.1)                  
##  rmarkdown    1.10    2018-06-11 CRAN (R 3.5.1)                  
##  rprojroot    1.3-2   2018-01-03 CRAN (R 3.5.1)                  
##  rstudioapi   0.7     2017-09-07 CRAN (R 3.5.1)                  
##  rvest        0.3.2   2016-06-17 CRAN (R 3.5.1)                  
##  scales       1.0.0   2018-08-09 CRAN (R 3.5.1)                  
##  snakecase    0.9.2   2018-08-14 CRAN (R 3.5.1)                  
##  stats      * 3.5.1   2018-07-02 local                           
##  stringi      1.2.4   2018-07-20 CRAN (R 3.5.1)                  
##  stringr    * 1.3.1   2018-05-10 CRAN (R 3.5.1)                  
##  tibble     * 1.4.2   2018-01-22 CRAN (R 3.5.1)                  
##  tidyr      * 0.8.1   2018-05-18 CRAN (R 3.5.1)                  
##  tidyselect   0.2.4   2018-02-26 CRAN (R 3.5.1)                  
##  tidyverse  * 1.2.1   2017-11-14 CRAN (R 3.5.1)                  
##  tools        3.5.1   2018-07-02 local                           
##  utils      * 3.5.1   2018-07-02 local                           
##  withr        2.1.2   2018-03-15 CRAN (R 3.5.1)                  
##  xfun         0.3     2018-07-06 CRAN (R 3.5.1)                  
##  xml2         1.2.0   2018-01-24 CRAN (R 3.5.1)                  
##  yaml         2.2.0   2018-07-25 CRAN (R 3.5.1)