This is an Rpubs test file!
setwd("~/Binghamton/DIDA 370/zip_codes")
library(sf)
library(ggplot2)
library(dplyr)
library(urbnmapr)
map <- st_read("cb_2019_us_zcta510_500k.shp")
Reading layer `cb_2019_us_zcta510_500k' from data source
`C:\Users\melha\OneDrive\Documents\Binghamton\DIDA 370\zip_codes\cb_2019_us_zcta510_500k.shp'
using driver `ESRI Shapefile'
Simple feature collection with 33144 features and 5 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -176.6847 ymin: -14.37374 xmax: 145.8304 ymax: 71.34132
Geodetic CRS: NAD83
colnames(map)[1] <- "zipcode"
map$zipcode <- as.numeric(map$zipcode)
map_ny <- map %>%
filter(zipcode > 09999 & zipcode < 15000)
ggplot(map_ny)+
geom_sf(fill = "white")
setwd("~/Binghamton/DIDA 370")
data <- read.csv("select_zipcode_statistics.csv")
library(tidyr)
library(tidyverse)
#join shapefile with survey data
ny1 <- map_ny %>%
left_join(data, by = c("zipcode" = "Geographic.Area.Name")) %>% drop_na() %>%
st_transform("EPSG:32116")
#get just Broome county
#load in NYS county shape file and set crs
counties <- get_urbn_map("counties", sf = TRUE)
#filter the data to get just NYS
broome <- counties %>%
filter(state_abbv == "NY") %>%
filter(county_name == "Broome County") %>%
st_transform("EPSG:32116")
old-style crs object detected; please recreate object with a recent sf::st_crs()
#isolate Broome County
broome_map <- ny1[broome,]
#plot it
ggplot(broome_map)+
geom_sf(mapping = aes(), fill = "white")+
theme_minimal()+
labs(title = "Broome County Zipcodes")