# Productivity Commission 2018 analysis for the Rising Inequality? Commission Research Paper # HILDA SETUP packages and functions, and define colours and colour palettes ################################################################################ # install.packages("here") # install.packages("readstata13") # install.packages("readxl") # install.packages("dplyr") # install.packages("Hmisc") # install.packages("tidyr") # install.packages("reldist") # install.packages("questionr") # install.packages("formattable") # install.packages("ggplot2") # install.packages("stringr") # install.packages("spatstat") # install.packages("survey") # not using at the moment # install.packages("acid") # install.packages("convey") # install.packages("devEMF") # install.packages("reshape2") # install.packages("ggalluvial") # install.packages("alluvial") # install.packages("devEMF") # install.packages("quantreg") # install.packages("ggrepel") # install.packages("svglite") # install.packages("grid") rm(list = ls()) # remove all objects # rm not needed if opening up blank gc() # garbage collector frees up memory # open all packages that will be used in script library(here) library(readstata13) library(readxl) library(dplyr) library(Hmisc) library(tidyr) library(reldist) library(questionr) library(formattable) library(ggplot2) library(stringr) library(convey) library(acid) library(spatstat) library(survey) library(devEMF) library(reshape2) library(ggalluvial) library(alluvial) library(devEMF) library(quantreg) library(ggrepel) library(svglite) library(grid) # define preferred functions where multiples exist (e.g. wtd.mean as Hmisc version so doesn't clash with a different version in another package - reldist) wtd.mean <- Hmisc::wtd.mean wtd.quantile <- Hmisc::wtd.quantile wtd.var <- Hmisc::wtd.var wtd.table <- questionr::wtd.table gini <- reldist::gini select <- dplyr::select lag <- dplyr::lag distinct <- dplyr::distinct ######################################################################################################## #### COLOUR PALETTE ######################################################################################################## #define custom colour palette blue <- rgb2hex(c(102,188,219)) mid_blue <- rgb2hex(c(44,149,186)) dark_blue <- rgb2hex(c(38,90,154)) PC_green <- rgb2hex(c(120,162,47)) dark_green <- rgb2hex(c(77,112,40)) yellow <- rgb2hex(c(244,177,35)) orange <- rgb2hex(c(241,90,37)) red <- rgb2hex(c(165,40,40)) purple <- rgb2hex(c(137,86,163)) dark_purple <- rgb2hex(c(103,64,122)) black <- rgb2hex(c(0,0,0)) grey <- rgb2hex(c(191,191,191)) dark_grey <- rgb2hex(c(64,64,64)) white <- rgb2hex(c(254,255,255)) # alluvial colours alluvial_green <- rgb2hex(c(178,214,115)) alluvial_blue <- rgb2hex(c(163,215,233)) alluvial_yellow <- rgb2hex(c(249,217,145)) # colour pallettes PCcols <- c(blue, dark_blue, PC_green, dark_green, yellow, orange, red, purple) PCcolsTen <- c(blue, mid_blue, dark_blue, PC_green, dark_green, yellow, orange, red, purple, dark_purple) PCcols1 <- c(blue, dark_blue, dark_green, yellow, orange, red, purple) PCcolsPres <- c(blue, PC_green, dark_green, yellow, orange, purple) PCcolsPresRev <- c( PC_green, blue) #Create extended ten colour palette PCcols_gradient <- scale_fill_gradientn(colours = PCcols, space = "Lab", na.value = "grey50", guide = "legend", breaks = seq(1,10,1)) PCcols_gradient_col <- scale_color_gradientn(colours = PCcols, space = "Lab", na.value = "grey50", guide = "legend", breaks = seq(1,10,1))