Curtin logo

Introduction to R - Data Literacy

Version 1.8 - July 2024

COPYRIGHT © Curtin University 2024

Workshop 1 - Part 7 - Interactive Map visualisations

Note: This Leaflet and Map Shapefile data was already loaded in the previous part of this workflow.

load(file = "pc_sf_raw.RData")

Leaflet Visualisation 2 - with Crosstalk filters

Interactive Crosstalk elements can be added to Leaflet visualisations too, though not with the Postcode shapes from earlier but with the labels of each Postcode.

In this visualisation, once again achieved with a relatively small amount of code, two sliders are used to select Postcodes based on SEIFA Index of Education and Occupation and also Private Health Cover Percentage.

What interesting correlations can you find?

# Visualisation 2
pc_v2_shared <- SharedData$new(pc_sf)

bscols(
  widths=c(6,6,12),
  filter_slider("ieo_percentile", "SEIFA Index of Education and Occupation", pc_v2_shared, column=~ieo_percentile, step=1, width = "100%"),
  filter_slider("PrivateHealth_percentpp", "Private Health Cover Percentage per Postcode", pc_v2_shared, column=~PrivateHealth_percentpp, step=1, width = "100%"),
  leaflet(pc_v2_shared) %>% 
    addPolygons(color="black",weight=0.3, smoothFactor=0.2, fillOpacity=0.5, fillColor="lightgrey", highlightOptions = highlightOptions(color="royalblue",weight=1)) %>% 
    addProviderTiles(providers$CartoDB.Voyager) %>% 
    addCircleMarkers(~long,~lat, label=~data_label, radius=2)
)