There and Back Again competition entry https://shiny.petras.space/commute/
rstats
rshiny
census
competition
leaflet
javascript
stats-nz
Petra Lamborn d5695ff2b6 More link messing 3 years ago
viz More link messing 3 years ago
.gitignore change shapefile; add keyboard shortcuts 3 years ago
README.md Add readme 3 years ago
commute.Rproj Start 3 years ago
maps.R Tidy up scratchwork 3 years ago
process.R Tidy up scratchwork 3 years ago
travel-education.csv Start 3 years ago
travel-work.csv Start 3 years ago

README.md

How did Kiwis commute in 2018?

This is an R Shiny and Leaflet data visualisation of the commuter data from the 2018 NZ Census of Populations and Dwellings; you can see it in action here. It serves as my entry for the 2020 There and Back Again data viz competition. The code for the visualisation itself is in the viz/ folder, however note that it requires the code in process.R to be run first to produce the .RData file, along with the separate download of a SA2 shapefile (in WGS projection, and possibly simplified by the code in maps.R).

Issues

Some problems with the code, for future personal reference.

The Chatham Islands

Unfortunately I had to remove the Chatham Islands from the map, despite it being in the dataset! This was because their position on the far side of the 180° meridian causes issues with leaflet maps on WGS projections, while I was unable to get an alternative projection to work.

Hovering

If you hover the cursor over a region, and then over the sea or a lake, the shiny code is capable of registering that you’re not over that same region still. However if you then return to the same region it doesn’t recognise that. This seems to be a limitation of how the shiny events stuff works. There might be something I can do with resetting the input$, but I’ll look into it later.