Test your data

I’ve written and spoken before about how important it is to test your functions and data analysis scripts. I decided to revisit these ideas and write this tutorial based on my recent experience of calculating the number of units of alcohol the panel members in the NCDS and BCS70 birth cohorts drank at different time points. I initially thought this would be a straightforward mathematical calculation but this turned out to be vastly more complicated than I thought (it always does! [Read More]

Pandoc error parsing BibTeX file

I get the following error so often (and I always forget how to solve it) that I thought I’d post a solution.

pandoc-citeproc: "stdin" (line 2421, column 2):
unexpected "m"
expecting "c", "C", "p", "P", "s" or "S"
pandoc: Error running filter /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
Filter returned error status 1
Error: pandoc document conversion failed with error 83
[Read More]

Geocoding with Google Geocoding API and Googleway

Geocoding is the process of taking an address, postcode, or other human–readable identifier and converting it into coordinates. Here I use the Google Geocoding API which I access within R with the googleway package. HUGOMORE42 Obtain a Google Geocoding API key To use the Google Geocoding API service we need an API key: Open the Get API Key page Click Get Started When asked, you need to enable the Places product. [Read More]

Automate image layout for comparison

For a project I’m working on I needed to compare three figures each for about 50 countries. Printing 150 images seemed like a waste (especially as I would need to print the images single–sided) and open three images to view on screen 150 times was likely to result in me opening the wrong image at least once. My solution was to group the three images for each country onto one image for me to easily compare, and print if necessary.

[Read More]

Spatial packages and Travis

A number of R spatial libraries have been updated in the last couple of weeks, and this has played havoc with my Travis–CI build. I had still been using Ubuntu Trusty with Travis which uses old versions of libraries like rgdal and rgeos, so I needed to move to updated versions of these. In addition sf has now become a dependency for a number of spatial packages like tmap, and this uses libudunits2-dev which isn’t installed by default. [Read More]
sf  travis  rstats  gis 

Simplify polygons without creating slivers

When you download geographical data the polygons are often highly detailed, leading to large file sizes and slow processing times. This tutorials shows you how to simplify detailed polygons in R and QGIS without creating slivers (gaps) between the resultant shapes. HUGOMORE42 When you download boundary data, for example from the census boundary data page, the polygons are usually highly detailed. Often this detail is unnecessary if you’re not intending to produce small–scale maps. [Read More]