library(tidyverse)
library(janitor)
library(leaflet)
<- read_csv("data/nhpd_chesterfield.csv") |>
nhpd clean_names() |>
filter(subsidy_status != "Inactive")
<- colorFactor(palette = c("blue", "red", "green", "orange"),
pal levels = c("LIHTC", "Section 8", "HUD Insured",
"Section 202 or Section 236"))
leaflet(nhpd) |>
addProviderTiles(providers$CartoDB.Positron) |>
addCircleMarkers(
lng = ~long,
lat = ~lat,
radius = 4,
color = ~pal(subsidy),
stroke = FALSE, fillOpacity = 0.5
|>
) addLegend("bottomright", pal = pal, values = ~subsidy,
title = "Federal program", opacity = 1)
4 Leaflet
This page is a demonstration of an interactive Leaflet map rendered in Quarto.