if (!require("pacman")) install.packages("pacman")

pacman::p_load(
  here,
  tidyverse,
  dplyr,
  lubridate,
  tidycensus,
  tigris,
  acs,
  leaflet,
  mapview,
  viridis,scales, janitor,gganimate, ggpmisc)

theme_set(theme_minimal())
names <- read.csv("NCCo Census Tract List.csv") %>% mutate(GEOID = as.character(GEOID))
shapefile <- tracts(state='10', county='03')

for_map <- geo_join(shapefile,names, by="GEOID")

popUp <- paste0("Census Tract: ", for_map$NAME,"<br>", "GEOID: ", as.character(for_map$GEOID),"<br>", "Neighborhood Name: ", for_map$Neighborhood)

for_map$val=for_map$NAME10

cols <- colorNumeric(
  palette = "magma",
  domain = for_map$val
)

lat <- 39.75821
lng <- -75.55229

filings_map<-leaflet() %>%
  addTiles("CartoDB.Positron") %>%   #not including one, sets the general maps version 
  setView(lng, lat, zoom = 12) %>%
  addPolygons(data = for_map, 
              fillColor = ~cols(for_map$val), 
              color = "#b2aeae", # you need to use hex colors
              fillOpacity = 0.5, 
              weight = 1, 
              smoothFactor = 0.2,
              popup = popUp)
filings_map