The ghostr package includes a dataset of over 800 ghost sightings in Kentucky, with information on city, latitude, and longitude, along with URLs for finding more information about the ghost sightings.

I’ve used a nice slimy green color here for the sightings, and the area of each circle is proportional to the number of sightings there.

Ain’t Afraid of No Ghost

That is very nice, but perhaps we would like to compare this to the populations in Kentucky cities and towns. Let’s find the population in towns and cities in Kentucky from the U.S. Census, using ACS table B01003. (If you haven’t used the acs package before, you will need to get an API key and run api.key.install() one time to install your key on your system.) I’ll use msa in the call to the ACS tables, which gets metropolitan/micropolitan statistical areas; this is about the best match to cities and towns you can get in the Census.

You can see here that this is fewer cities and towns than we had for the ghost sightings; there are ghost sightings records in some very small towns. Also, the acs package is great but working with it always involves a) lots of regex and b) lots of tidying. Anyway, now we need the latitude and longitude for these metropolitan and micropolitan areas; these are available from the Census.

Pretty nice! It looks to me like there are more ghost sightings in areas of higher population, but basically there are ghosts everywhere in Kentucky. The eastern part of Kentucky seems particularly full of ghosts relative to people.

The End

I am glad to have figured out a few things about Leaflet; it is very nice to use. Thanks to Kyle Walker and Kent Russell who helped me figure out how to get the maps to display at the right width both on desktop and mobile! The R Markdown file used to make this blog post is available here. I am very happy to hear feedback or questions!