This online walkthrough accompanies a 3h “show-and-tell” workshop on making thematic (choropleth) maps in R.

The worked examples demonistrate the quickest routes for getting your data in R and on a map, with a focus on showing how spatial data can be integrated in a familiar tidyverse data-analysis workflow.

The examples demonstrate mainly static maps, but interactive thematic maps are included as well. R packages demonistrated are primary

Intended audience is basic R users (or those interested in seeing what R can do), who wish integrate spatial data into their “regular” (exploratory) data-analysis workflow, or who need a quick map. More advanced GIS-topics such as projection fall outside of the scope.

The material and examples are structured along the basic steps you generally take when making thematic maps:

1. Motivating examples of static and interactive thematic maps.
2. Get an appropriate blank map to visualise your data on, e.g. from Belgium, Europe or the world.
4. Jointly manipulate your spatial and “regular” data.
5. Finally, plot and tweak your map. E.g. choosing color palettes, multiple maps, styling, etc.

I like hearing from you if this walkthrough has been useful somehow, if something is not working or can be improved, or if you are interested in a workshop.

You can copy-past the code snippets from the online pages, download (25MB) the entire set of material, or clone from Github.

Opening the file thematic_maps_with_r.Rproj in the downloaded folder launches an Rstudio-project, after which you should be able to open, adapt, and run the Rmarkdown notebooks containing the examples (files ending in .Rmd).

# Setup

3. Run commands below to install required R-packages.
install.packages('rmarkdown')
install.packages('sf')
install.packages('tmap')
install.packages('dplyr')
install.packages('eurostat')
install.packages('leaflet')
install.packages('haven')
install.packages('mapview')
install.packages('rgdal')
install.packages('tmaptools')
install.packages('countrycode')
install.packages('stringr')
install.packages("BelgiumMaps.StatBel", repos = "http://www.datatailor.be/rcube", type = "source")