I recently delivered a workshop on a practical introduction to shiny, an R package that enables development, testing and deployment of interactive web applications. Delivered at the University of Sydney’s Institute for Transport and Logistics Studies (ITLS), it was designed for people who are a) fairly new to R (which can seem intimidating) and b) completely new to shiny.
This article provides resources for people wanting to apply shiny to real-world applications and some context which explains the motivations behind running the workshop. The pdf tutorial, example code to create and modify your own apps and a place to contribute to this free teaching resource is available at the following GitHub repository: github.com/Robinlovelace/learning-shiny
My first shiny app
My first shiny app was rentSplit, which overcomes the problem faced when people move in together but can’t decide on who should pay what because some rooms are better than others. (I would like to add ‘income’ to this app to allow for minted people to pay more!):
The relatively painless experience of creating this app made me wonder if shiny could be used in transport policy applications and help us achieve the transition away from fossil fuels that scientists say is needed to avoid dangerous climate change.
To put shiny in the context of transport planning I began with a talk on the motivations behind online visualisation tools: the increased focus on ‘impact’ in academic funding decisions, the need for public engagement and the democratisation of decision-making processes, as illustrated by the interactive web map created by transport consultancy Steer Davies Gleave (SDG) to enable geolocated online discussion of a new £20 million cycle path that will connect the English cities of Leeds and Bradford:
This is a fantastic example of the new levels of engagement unleashed by online digital technologies such as Leaflet and shiny: for the first time ever, people can voice their opinions and pinpoint them to a specific place on the map in a real-time discussion. The potential for improving transparency and accountability in transport decision making is huge, as I described in a short article on web-mapping and as outlined in an academic paper on the subject (Schulz and Newig, 2014).
As stated in the talk, the audio of which is available online (see below), this is a fast-moving area that is likely to grow rapidly in the coming years. So it’s worth knowing what’s out there and what is possible at present.
The practical avoids reinventing the wheel
by building on and creating a narrative for RStudio’s excellent tutorial and documentation of shiny. For example, the
himod shiny app is simply a modified
version of the ‘01_hello’
demonstration app used to illustrate how new
widgets are created and how to
use their id’s as objects (via
input$id) in server.R:
So please take a look at the resources generated for this practical. I’d be interested to hear peoples’ thoughts on online interactive tools for transport planning and the digital democracy agenda. More specifically, what’s the simplest way to get an interactive map on shiny, as illustrated by the impressive map of the USA in the SuperZip shiny Gallery example?