NYC Squirrel Census

Map visualization (ggmap package)

Published

October 31, 2019

Notable topics: Map visualization (ggmap package)

Recorded on: 2019-10-31

Timestamps by: Alex Cookson

View code

Screencast

Timestamps

geom_point

Starter EDA of latitude and longitude using geom_point

Aggregating squirrel counts by hectare to get a "binned" map

Investigating colour notes

Asking question, "Are there areas of the parks where we see certain-coloured squirrels

Plotting latitude and percentage of gray squirrels to answer, "Do we get a lower proportion of gray squirrels as we go farther north?"

Using logistic regression to test gray squirrel (proportion as we go farther north)

Noting that he could have used original data sets as input for logistic regression function

"Does a squirrel run away?" based on location in the park (latitude), using logistic regression

summarise_at

Using summarise_at function to apply same function to multiple variables

ggmap

Loading ggmap package

get_map
ggmap

Start using ggmap, with the get_map function

Decision to not set up Google API key to use ggmap properly

sf

Using the sf package to read in a shapefile of Central Park

read_sf
sf

Using read_sf function from sf package to import a shapefile into R

geom_sf
sf

Using geom_sf function from sf package to visualise the imported shapefile

Combining shapefile "background" with relevant squirrel data in one plot

Visualising pathways (footpaths, bicycle paths) in the shapefile

Finishing visualisation and moving on to analysing activity types

ends_withgather

Selecting fields based on whether they end with "ing", then gathering those fields into tidy format

shiny

Decision to create a Shiny visualisation

shiny

Setting Shiny app settings (e.g., slider for minimum number of squirrels)

shiny

Setting up Shiny app options / variables

shiny

Explanation of why setting up options in Shiny app the way he did

shiny

Solving error "Discrete value supplied to continuous scale"

shiny

First draft of Shiny app

shiny

Creating a dynamic midpoint for the two-gradient scale in the app

shiny

Adding additional variables of more behaviours to Shiny app (kuks, moans, runs from, etc.)

"What are the distributions of some of these [behaviours]?"

shiny

Adding ground location (above ground, ground plane) to Shiny app

Summary of screencast