You are interested in understanding how the biodiversity of birds varies in
response to environmental variables and decide to conduct your analysis in a
reproducible manner using knitr
and rmarkdown
. Specifically you want to know
how species richness (the number of species seen at a site) varies in response
to the mean annual temperature and the mean annaual precipitation.
Rmd
document with a title and author and set the output format
to html_document
.message = FALSE
.rdataretriever
package. Instructions for installing this package and the
associated Python package are available on the
Data Retriever website. It will take a
long time to download and convert this data into a set of useable CSV files
(~30 minutes), so add a conditional statement that checks to see if the
necessary files have already been created and only install they data if they
have not. Don’t show the output for this chunk.Make a map of the locations of all of the Breeding Bird Survey routes,
including an outline the North America landmass. Add a header above this map
describing what it shows. You can get a world map useing
usmap = map_data("world")
, which you can then plot using geom_polygon
.
To only show this data in the region of the Breeding Bird Survey routes add
the following to you ggplot
command:
scale_x_continuous(limits = c(min(routes$longitude), max(routes$longitude))) +
scale_y_continuous(limits = c(min(routes$latitude), max(routes$latitude)))
getData
function from the raster
package to obtain the bioclim
data (getData('worldclim', var = 'bio', res = 10)
) and extract
the values
for each route. Convert resulting matrix into a data frame and select
just
the mean annual temperature (bio1) and the mean annual precipitation (bio1).
Use cbind
to combine these two predictor columns with the routes table.statenum
and route
columns. Join this
data with the predictor data you obtained in (7).Display the new table data.bio1
and
richness
and bio12
and richness
. Include the raw data points and a
smooth line through them. (optional) Try doing this with a function if you
want an extra challenge..bib
file to hold your bibtex
citations. You can obtain bibtex for the citations by searching Google
Scholar for “Breeding Bird Survey” and “Worldclim”, clicking on the "
icon, and selecting bibtex
. You should also add a References
header at
the bottom of your document since the references will appear at the end.