Rows: 177 Columns: 13
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): NEIGHBORHOOD_NAME, BOROUGH_GROUP, label
dbl (10): MODIFIED_ZCTA, lat, lon, COVID_CASE_COUNT, COVID_CASE_RATE, POP_DE...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Reading layer `ZIP_CODE_040114' from data source
`C:\Users\erins\Downloads\R-Spatial_I_Lab (1)\ZIP_CODE_040114\ZIP_CODE_040114.shp'
using driver `ESRI Shapefile'
Simple feature collection with 263 features and 12 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 913129 ymin: 120020.9 xmax: 1067494 ymax: 272710.9
Projected CRS: NAD83 / New York Long Island (ftUS)
Show the code
covid_data <- tests %>%mutate(MODIFIED_ZCTA =as.character(MODIFIED_ZCTA))# perform the joinnyc_zip_joined_new <- nyc_zip %>%left_join(covid_data, by =c("ZIPCODE"="MODIFIED_ZCTA"))pal1 <-brewer.pal(7, "Reds")pal2 <-brewer.pal(7, "Blues")# change the jenks for both the different variables because they have very different needsbreaks1 <-classIntervals(nyc_zip_joined_new$COVID_DEATH_RATE, n =7, style ="jenks")$brks
Warning in classIntervals(nyc_zip_joined_new$COVID_DEATH_RATE, n = 7, style =
"jenks"): var has missing values, omitted in finding classes
Show the code
breaks2 <-classIntervals(nyc_zip_joined_new$TOTAL_COVID_TESTS, n =7, style ="jenks")$brks
Warning in classIntervals(nyc_zip_joined_new$TOTAL_COVID_TESTS, n = 7, style =
"jenks"): var has missing values, omitted in finding classes
Show the code
# Assign colors based on breaksnyc_zip_joined_new$color1 <-cut(nyc_zip_joined_new$COVID_DEATH_RATE, breaks = breaks1, labels = pal1, include.lowest =TRUE)nyc_zip_joined_new$color2 <-cut(nyc_zip_joined_new$TOTAL_COVID_TESTS, breaks = breaks2, labels = pal2, include.lowest =TRUE)plot(nyc_zip_joined_new["COVID_DEATH_RATE"], breaks = breaks1, col = pal1, graticule =st_crs(4326),axes =TRUE, reset =FALSE,main ="COVID Death Rate")
Warning in plot.sf(nyc_zip_joined_new["COVID_DEATH_RATE"], breaks = breaks1, :
col is not of length 1 or nrow(x): colors will be recycled; use pal to specify
a color palette
Show the code
# 1st legend for COVID Death Ratelegend("topright", legend =round(breaks1, 2), fill = pal1, title ="COVID Death Rate", cex =0.8)
Warning in plot.sf(nyc_zip_joined_new["TOTAL_COVID_TESTS"], breaks = breaks2, :
col is not of length 1 or nrow(x): colors will be recycled; use pal to specify
a color palette
Show the code
# second legend for Total COVID Testslegend("topright", legend =round(breaks2, 2), fill = pal2, title ="Total COVID Tests", cex =0.8)
task 2:
Show the code
censustracts <- sf::st_read('R-Spatial_II_Lab/2010 Census Tracts/geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.shp', stringsAsFactors =FALSE)
Reading layer `geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a' from data source `C:\Users\erins\Downloads\R-Spatial_II_Lab\2010 Census Tracts\geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.shp'
using driver `ESRI Shapefile'
Simple feature collection with 2165 features and 11 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -74.25559 ymin: 40.49612 xmax: -73.70001 ymax: 40.91553
Geodetic CRS: WGS84(DD)