Encounter Report Code

updated 3/18/2019 by Lindsay Carlson

Instructions: You will need to install the packages above for this document to work. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. To run one code chunk at a time, press the green arrow on the right hand side. Chunks must be run in order. To run everything above the current chunk, press the down arrow with the green bar underneath.

Summary Statistics

Create a table of number of reported bands by state. Use “dplyr” to group by state, count n, and filter states where fewer than 10 bands were reported. Use fct_reorder in “forcats” to reorder by n. 

Distance from banding location

Calculate distance from banding location lat/long to encounter location lat/long using distm function in “geosphere.” Create table of distance summary statistics by month of encounter.

Month of Encounter Mean Dist from Banding Location n Min Max SD SE
Jan 211.98147 309 0.8933529 1547.93484 197.08736 11.21191
Feb 158.95840 9 10.6182944 430.48404 170.15725 56.71908
Mar 42.27806 2 15.7635814 68.79254 37.49713 26.51448
Apr 2315.43319 5 1952.6548189 2612.51995 249.28788 111.48493
May 1162.12114 1 1162.1211385 1162.12114 NaN NA
Aug 1965.12910 6 1342.8608556 2485.46650 427.88534 174.68346
Sept 1811.22357 24 68.2988719 2735.92392 612.33942 124.99326
Oct 1789.08755 102 246.5325826 2689.93183 530.05963 52.48372
Nov 540.98240 143 0.7085300 2326.68876 494.56082 41.35725
Dec 325.82698 213 0.6912063 2771.06183 332.87523 22.80823

Animated Maps

Create an animated map where encounter locations are shown by date (since 2015). Use “gganimate” and “ggmap.”

##           0 1.September   2.October  3.November  4.December   5.January 
##          23          24         102         143         213         309

Create a density map for each “hunting season” as opposed to each year. Show monthly harvest density. This figure includes data for mallards only.

## 2014-2015 2015-2016 2016-2017 2017-2018 2018-2019 
##         4        48        98       330       311

Animate the mallard density map by monthly density.