Naomi Thornhill Assignment 7 install.packages(“sf”) library(sf) library(ggplot2) library(readr) file_path <- “NYS_Health_Facility.csv” colnames(NYS_Health_Facility) Lat<-as.numeric(NYS_Health_Facility\(`Facility Latitude`) Long<-as.numeric(NYS_Health_Facility\)Facility Longitude) df_clean <- NYS_Health_Facility[!is.na(Lat) & !is.na(Long), ] nys_health_sf <- st_as_sf(df_clean, coords = c(“Facility Longitude”, “Facility Latitude”), crs = 4326) mapview(gdf,legend = TRUE)

leftPos <- stringr::str_locate(NYS_Retail_Food_Stores\(Location, "\\(")[,1] rghtPos <- stringr::str_locate(NYS_Retail_Food_Stores\)Location, “\)”)[,1] NYS_Retail_Food_Stores\(Coords <- stringr::str_sub(NYS_Retail_Food_Stores\)Location, leftPos + 1, rghtPos - 1) cmmaPos <- stringr::str_locate(NYS_Retail_Food_Stores\(Coords, ", ") NYS_Retail_Food_Stores\)Y <- as.numeric(stringr::str_sub(NYS_Retail_Food_Stores\(Coords, 1, cmmaPos[,1] - 1)) NYS_Retail_Food_Stores\)X <- as.numeric(stringr::str_sub(NYS_Retail_Food_Stores$Coords, cmmaPos[,2] + 1)) NYS_Retail_Food_Stores <- tidyr::drop_na(NYS_Retail_Food_Stores, X, Y) nysFoodStoreSF <- st_as_sf(NYS_Retail_Food_Stores, coords = c(‘X’, ‘Y’)) mapview(nysFoodStoreSF, legend = TRUE)

save(nys_health_sf,file = “nys_health_sf.RData”) save(nysFoodStoreSF,file = “nysFoodStoreSF.RData”)