Quantcast
Channel: r software hub
Viewing all articles
Browse latest Browse all 1015

Mapping Birds with Choroplethr

$
0
0

By Ari Lamstein

bird

The bird in question. But where does it live? Credit: Wikipedia.

After releasing my course Mapmaking in R with Choroplethr last December I received an interesting email from Dr. Herb Wilson, a biologist at Colby College. Herb studies the Red-breasted Nuthatch, which live throughout the United States and Canada. He asked if it was possible to use choroplethr to map the location of these birds. Herb’s data was a list of (region, value) pairs, where the regions are US States and Canadian Provinces.

At that time it was possible to use the function ?admin1_choropleth to map the birds in US States or Canadian Provinces, but not both simultaneously. So I created a new function for him, ?admin1_region_choropleth, which solves this exact problem.

The code is now on CRAN. Below is a tutorial on how to use it.

The Code

To get the latest version of choroplethr, simply install it from CRAN and check its version:

install.packages("choroplethr")
packageVersion("choroplethr")
[1] ‘3.5.0'

If you see a lower version (for example 3.4.0), then you need to wait a day or two until your CRAN mirror updates.

The new function is called admin1_region_choropleth. You can see its built-in help like this:

?admin1_region_choropleth

The Data

The bird count data comes from the annual Christmas Bird Count run by the National Audubon Society. I have put it in a github repository which you can access here. Once you download the file you can read it in like this:

library(readr)
rbn = read_csv("~/Downloads/rbn.csv")

head(rbn)
Source: local data frame [6 x 8]

State AdminRegion Count_yr SpeciesNumber NumberByPartyHours Year ReportingCounts ReportingObservers
(chr) (chr) (int) (int) (dbl) (int) (int) ...read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles