Adding points from multiple dataframes to R-leaflet maps

I’ve been getting interested in plotting electoral data onto maps — and as a result have been looking at how combinations of information might explain the results of the 2019 election.

To do so, i have been plotting the booth-by-booth results onto a map, as well as data from other information sources.  This was tricky initially, but once you get the knack it makes a lot of sense (in that Hadley Wickham way).

The key is  moving the data = XYZ bit from inside the leaflet() function to the first argument of the addCircleMarkers() function.

The other trick to note below is that I set the  bins for the colorBin function manually.  This is necessary, as the mid point of the range is not zero.

Building on my earlier single-layer maps example, in this case we have the location of mines and the two-party-preferred election 2019 results by polling booth.

One thought on “Adding points from multiple dataframes to R-leaflet maps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s