<jupyter_start><jupyter_text>**Violin Plot**This notebook demonstrates a violin plot.The key parameters need to be edited in the Parameters section below, in particular for selecting the data of interest.<jupyter_code>#  Load the required libraries

library(sf)
library(ggplot2)<jupyter_output><empty_output><jupyter_text>Parameters<jupyter_code>#  Insert the dataset name and variable of interest

## Dataset
dataset.param <- "ABS_-_Jobs_In_Australia_-_All_Jobs__SA2__2011-2018.json"

## Variable of Interest
variable.param <- "p_2017_18_median_employment_income_per_job_aud"

## Region Parameter
region.param <- "state"<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>setwd("/home/jovyan/aurin")                                                    # Set the working directory
getwd()
dataset.sf <-  st_read(paste("data/violin/", dataset.param, sep = ""))                # Load the GeoJSON dataset<jupyter_output><empty_output><jupyter_text>Prepare Data<jupyter_code>dataset.sf[[region.param]] <- substr(dataset.sf$sa2_main16, 1, 1)
dataset.sf[[region.param]] <- factor(dataset.sf$state,
                    levels = c(1,2,3,4,5,6,7,8),
                    labels = c("NSW", "VIC", "QLD", "SA", "WA", "TAS", "NT", "ACT"))<jupyter_output><empty_output><jupyter_text>Plot Visualisation<jupyter_code>ggplot(dataset.sf, aes(x = state, y = dataset.sf[[variable.param]])) + 
  geom_violin(aes(fill = state)) +
  labs(title="Median Employment Income 2017-2018", x="State", y="Median Income $")<jupyter_output>Warning message:
“Removed 41 rows containing non-finite values (stat_ydensity).”<jupyter_text>Save Visualisation<jupyter_code>ggsave("img/violin.png", plot = last_plot())<jupyter_output>Saving 6.67 x 6.67 in image

Warning message:
“Removed 41 rows containing non-finite values (stat_ydensity).”
StarcoderdataJupyterStructuredCleanDedup