Markets
: farmers markets
Gardens
: community gardens
Stores
: healthy stores
library(shiny)
library(leaflet)
library(maptools)
library(tidyverse)
library(shiny)
# Reading in the data for the resources
farmer_markets =
read_csv(file= "./data/DOHMH_Farmers_Markets.csv")
gardens =
read_csv(file = "./data/NYC_Greenthumb_Community_Gardens.csv")
healthy_stores=
read_csv(file = "./data/Recognized_Shop_Healthy_Stores.csv")
# Doing the data cleaning for the datasets
farmer_markets_clean =
farmer_markets %>%
janitor::clean_names() %>%
rename("Borough" = borough,
"Market"= market_name,
"Latitude" = latitude,
"Longitude" = longitude) %>%
select(Borough,Latitude, Longitude, Market) %>%
drop_na()
gardens_clean =
gardens %>%
janitor::clean_names() %>%
rename("Borough" = boro,
"Garden"= garden_name,
"Latitude"= latitude,
"Longitude" = longitude) %>%
mutate(Borough = recode(Borough, "M"= "Manhattan",
"B"= "Brooklyn",
"X"= "Bronx",
"Q"= "Queens",
"S"= "Staten Island")) %>%
select(Borough, Latitude, Longitude, Garden) %>%
drop_na ()
healthy_stores_clean =
healthy_stores %>%
janitor::clean_names() %>%
rename("Borough"= borough,
"Store"= store_name,
"Latitude"= latitude,
"Longitude" = longitude) %>%
select(Borough, Latitude, Longitude, Store) %>%
drop_na()
# Going to join the data all together
joined_data_1 =
full_join(farmer_markets_clean, gardens_clean, by = c("Borough","Latitude", "Longitude"))
Complete_data=
full_join(joined_data_1, healthy_stores_clean, by = c("Borough", "Latitude", "Longitude")) %>%
pivot_longer(
Market:Store,
values_to = "Name",
names_to = "Type"
) %>%
group_by(Type, Name, Borough) %>%
drop_na() %>%
mutate(Label= str_c("<b>", Name, "</b><br>", Type, sep=""))
NYC_map =
leaflet(Complete_data) %>%
addTiles(
urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>'
) %>%
addMarkers(~Longitude, ~Latitude, popup = ~Label, label = ~Name )
NYC_map
For more information, please see the following links: