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)
)

Key Learning

Key Learning #6 - Datasets with common ‘keys’ can be combined to allow for more powerful analysis.

Key Learning #7 - R can perform SQL style queries with external SQL databases.

Key Learning #8 - Interactive visualisations are best; the user is not dictated to, instead they are guided and can choose their own analysis journey. Incorporating intuitive elements can allow even more insights.

Key Learning #9 - Web browsers are the ideal vehicle to use for sharing visualisations. R has many tools which can present visualisations using only the web browser, no need for other software or databases/data servers.

Further Learning

Further Learning #3 RShiny is a well documented and widely used library to achieve interactivity in visualisations.

Previous

Part 6 - Interactive visualisations

Next

Part 8 - Next steps

Curtin logo

Version 1.8 - July 2024

COPYRIGHT © Curtin University 2024