Learning about classes in R with plot.bike()

A useful feature of R is its ability to implement a function differently depending on the ‘class’ of the object acted on. This article explores this behaviour with reference to a playful modification of the ‘generic’ function plot() to allow plotting of cartoon bicycles. Although the example is quite simple and fun, the concepts it touches on are complex and serious.

The example demonstrates several of the programming language paradigms that R operates under. R is simultaneously object-orientated, functional and polymorphic. The example also demonstrates the paradigm of inheritance, through the passing of arguments from plot.bike() to plot() via the ... symbol. There has been much written about programming paradigms and R’s adherence to (or flouting of!) them. Two useful references on the subject are a Wikibook page on programming language paradigms and Hadley Wickham's Advanced R book. There is a huge amount of information on these topics. For the purposes of the examples presented here suffice to say that R uses multiple paradigms and is extremely flexible.

Continue reading

R vs QGIS for sustainable transport planning

The 23rd iteration of the GIS Research UK conference (#GISRUK) conference was the largest ever. 250 researchers, industry representatives and academics attended from the vibrant geospatial research communities in the UK, Europe and beyond. GISRUK has become a centrepoint for discussion of new methods, software and applications in the field. I was on the organising committee, reviewed some excellent papers for the event (a full list of these is available for download here) and attended some truly ground-breaking talks. This experience has shown that the geospatial community in the UK is strong, especially with regards to growth in open access data and open source software in the field.


Continue reading

R for spatial data slides

These are the updated slides from my popular tutorial, Introduction to visualising spatial data in R. These slides, and the entire tutorial, are open source and available to anyone free of charge online. See https://github.com/Robinlovelace/Creating-maps-in-R for more information.

The leaflet package for online mapping in R

It has been possible for some years to launch a web map from within R. A number of packages for doing this are available, including:

  • RgoogleMaps, an interface to the Google Maps api
  • leafletR, an early package for creating Leaflet maps with R
  • rCharts, which can be used as a basis for webmaps

In this tutorial we use the new RStudio-supported leaflet R package. We use this package, an R interface to the JavaScript mapping library of the same name because:

  • leaflet is supported by RStudio, who have a track strong track record of creating amazing R packages
  • leaflet appears to provide the simplest, fastest way to host interactive maps online in R, requiring only 2 lines of code for one web map! (as you’ll see below)
  • leaflet is shiny. Shiny in the literal sense of the word (a new and fresh approach to web mapping in R) but also in the sense that it works well with the R package shiny.

Continue reading

Practical introduction to Shiny - workshop write-up

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

Continue reading

My space

Search this site!

What I'm up to

To see public events I'm attending please check out the calendar below. If that doesn't load, please see the html version here

Quote of the day

Some interesting links

The internet is awash with detritus. In the name of navigating the maze, these links highlight some more enlightened online content.

George Monbiot: investigative journalism at its best

R-Bloggers: a site endevouring to make statistics accessible and fun

Tom's bike trip: there are many 'bike trip' sites out there; this is one of the best

Personal links:

My presentations on Speaker Deck

TGRG website: the Transport Geography group I'm involved with

MASS profile: academic profile at Leeds

Powerstar Youtube channel: check out my videos

R-Bloggers feed: posts about R

Site map

This page should help navigate the site.