library(geojsonio)
## Registered S3 method overwritten by 'geojsonsf':
## method from
## print.geojson geojson
##
## Attaching package: 'geojsonio'
## The following object is masked from 'package:base':
##
## pretty
library(leaflet)
library(gganimate)
## Loading required package: ggplot2
## No renderer backend detected. gganimate will default to writing frames to separate files
## Consider installing:
## - the `gifski` package for gif output
## - the `av` package for video output
## and restarting the R session
library(rvest)
library(png)
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ✔ purrr 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ readr::guess_encoding() masks rvest::guess_encoding()
## ✖ dplyr::lag() masks stats::lag()
library(dplyr)
library(ggpubr)
library(stringr)
nyc_squirrels365 = read.csv("2018_Central_Park_Squirrel_Census_-_Squirrel_Data.csv")
nyc_squirrels365 %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(lng = ~X,
lat = ~Y, clusterOptions = markerClusterOptions())
pallettes <- colorFactor(c("#000000", "#D2691E", "#D3D3D3", "white"), domain = c("Black", "Cinnamon", "Grey", "NA"))
nyc_squirrels365 %>%
filter(!is.na(Primary.Fur.Color)) %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(lng = ~X,
lat = ~Y, radius = 3, color = ~pallettes(Primary.Fur.Color), stroke = FALSE, fillOpacity = 0.5) %>%
addLegend(position ="bottomright",pal = pallettes, values = ~Primary.Fur.Color)
## Warning in pallettes(Primary.Fur.Color): Some values were outside the color
## scale and will be treated as NA
## Warning in pallettes(Primary.Fur.Color): Some values were outside the color
## scale and will be treated as NA
## Warning in pal(v): Some values were outside the color scale and will be treated
## as NA