Load packages

R Spaital Lab Assignment # 1

1.6 Lab Assignment For the R-Spatial Section labs, we will do some spatial data visualization on COVID-19 in NYC. More specifically, we will explore the distribution of confirmed cases across the city and their relationships with some demographic variables and essential services related to retail food stores and public health services.

task 1: Set up a R project for the R-Spatial section.

task 2: Read the NYC postal areas in Shapefiles into sf objects. As NYC DOH publishes COVID-19 data by zip code, we will utilize the postal area data later.

# Load NYC postal areas file
nyc_postal_areas <- st_read("C:/Users/melin/Documents/GTECH78520/part3/ZIP_CODE_040114/ZIP_CODE_040114.shp")
## Reading layer `ZIP_CODE_040114' from data source 
##   `C:\Users\melin\Documents\GTECH78520\part3\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)
# Create sf object from geographic coordinates
nyc_postal_areas_sf <- st_as_sf(nyc_postal_areas, coords = c("X", "Y"), crs = 4326)

# Look at the new sf object
str(nyc_postal_areas_sf)
## Classes 'sf' and 'data.frame':   263 obs. of  13 variables:
##  $ ZIPCODE   : chr  "11436" "11213" "11212" "11225" ...
##  $ BLDGZIP   : chr  "0" "0" "0" "0" ...
##  $ PO_NAME   : chr  "Jamaica" "Brooklyn" "Brooklyn" "Brooklyn" ...
##  $ POPULATION: num  18681 62426 83866 56527 72280 ...
##  $ AREA      : num  22699295 29631004 41972104 23698630 36868799 ...
##  $ STATE     : chr  "NY" "NY" "NY" "NY" ...
##  $ COUNTY    : chr  "Queens" "Kings" "Kings" "Kings" ...
##  $ ST_FIPS   : chr  "36" "36" "36" "36" ...
##  $ CTY_FIPS  : chr  "081" "047" "047" "047" ...
##  $ URL       : chr  "http://www.usps.com/" "http://www.usps.com/" "http://www.usps.com/" "http://www.usps.com/" ...
##  $ SHAPE_AREA: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ SHAPE_LEN : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ geometry  :sfc_POLYGON of length 263; first list element: List of 1
##   ..$ : num [1:159, 1:2] 1038098 1038142 1038171 1038280 1038521 ...
##   ..- attr(*, "class")= chr [1:3] "XY" "POLYGON" "sfg"
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
##   ..- attr(*, "names")= chr [1:12] "ZIPCODE" "BLDGZIP" "PO_NAME" "POPULATION" ...

task 3: Read and process the NYS health facilities spreadsheet data. Create sf objects from geographic coordinates.

# Read the NYS health facilities spreadsheet data
health_facilities <- read.csv("C:/Users/melin/Documents/GTECH78520/part3/NYS_Health_Facility.csv")

#take a look at the data to get the name of the columns for the longitude and latitude (x,y) coordinates
str(health_facilities)
## 'data.frame':    3990 obs. of  36 variables:
##  $ Facility.ID                 : int  204 620 654 1156 2589 3455 3853 4249 4473 6230 ...
##  $ Facility.Name               : chr  "Hospice at Lourdes" "Charles T Sitrin Health Care Center Inc" "Central Park Rehabilitation and Nursing Center" "East Side Nursing Home" ...
##  $ Short.Description           : chr  "HSPC" "NH" "NH" "NH" ...
##  $ Description                 : chr  "Hospice" "Residential Health Care Facility - SNF" "Residential Health Care Facility - SNF" "Residential Health Care Facility - SNF" ...
##  $ Facility.Open.Date          : chr  "06/01/1985" "02/01/1989" "02/01/1989" "08/01/1979" ...
##  $ Facility.Address.1          : chr  "4102 Old Vestal Road" "2050 Tilden Avenue" "116 Martin Luther King East" "62 Prospect St" ...
##  $ Facility.Address.2          : chr  "" "" "" "" ...
##  $ Facility.City               : chr  "Vestal" "New Hartford" "Syracuse" "Warsaw" ...
##  $ Facility.State              : chr  "New York" "New York" "New York" "New York" ...
##  $ Facility.Zip.Code           : chr  "13850" "13413" "13205" "14569" ...
##  $ Facility.Phone.Number       : num  6.08e+09 3.16e+09 3.15e+09 5.86e+09 5.86e+09 ...
##  $ Facility.Fax.Number         : num  NA NA NA NA NA ...
##  $ Facility.Website            : chr  "" "" "" "" ...
##  $ Facility.County.Code        : int  3 32 33 60 2 14 29 14 29 7093 ...
##  $ Facility.County             : chr  "Broome" "Oneida" "Onondaga" "Wyoming" ...
##  $ Regional.Office.ID          : int  3 3 3 1 1 1 7 1 7 5 ...
##  $ Regional.Office             : chr  "Central New York Regional Office" "Central New York Regional Office" "Central New York Regional Office" "Western Regional Office - Buffalo" ...
##  $ Main.Site.Name              : chr  "" "" "" "" ...
##  $ Main.Site.Facility.ID       : int  NA NA NA NA NA NA NA NA NA 1463 ...
##  $ Operating.Certificate.Number: chr  "0301501F" "3227304N" "3301326N" "6027303N" ...
##  $ Operator.Name               : chr  "Our Lady of Lourdes Memorial Hospital Inc" "Charles T Sitrin Health Care Center, Inc" "CPRNC, LLC" "East Side Nursing Home Inc" ...
##  $ Operator.Address.1          : chr  "169 Riverside Drive" "Box 1000 Tilden Avenue" "116 Martin Luther King East" "62 Prospect Street" ...
##  $ Operator.Address.2          : chr  "" "" "" "" ...
##  $ Operator.City               : chr  "Binghamton" "New Hartford" "Syracuse" "Warsaw" ...
##  $ Operator.State              : chr  "New York" "New York" "New York" "New York" ...
##  $ Operator.Zip.Code           : chr  "13905" "13413" "13205" "14569" ...
##  $ Cooperator.Name             : chr  "" "" "" "" ...
##  $ Cooperator.Address          : chr  "" "" "" "" ...
##  $ Cooperator.Address.2        : chr  "" "" "" "" ...
##  $ Cooperator.City             : chr  "" "" "" "" ...
##  $ Cooperator.State            : chr  "New York" "New York" "New York" "New York" ...
##  $ Cooperator.Zip.Code         : int  NA NA NA NA NA NA NA NA NA NA ...
##  $ Ownership.Type              : chr  "Not for Profit Corporation" "Not for Profit Corporation" "LLC" "Business Corporation" ...
##  $ Facility.Latitude           : num  42.1 43.1 NA 42.7 42.1 ...
##  $ Facility.Longitude          : num  -76 -75.2 NA -78.1 -78 ...
##  $ Facility.Location           : chr  "(42.097095, -75.975243)" "(43.05497, -75.228828)" "" "(42.738979, -78.12867)" ...
#because there are missing values in the "Facility.Longitude" and "Facility.Latitude" columns of the health_facilities dataframe and the st_as_sf() function doesn't allow missing values, i first removed all rows with missing values.
health_facilities <- na.omit(health_facilities) 

#create sf object
health_facilities_sf <- st_as_sf(health_facilities, coords = c("Facility.Longitude", "Facility.Latitude"), crs = 4326) #To make it a complete geographical object we assign the WGS84 projection, which has the EPSG code 4326

#take a look at the sf object
str(health_facilities_sf)
## Classes 'sf' and 'data.frame':   100 obs. of  35 variables:
##  $ Facility.ID                 : int  9381 9527 9056 9428 102 9377 9225 9371 9624 9146 ...
##  $ Facility.Name               : chr  "Clifton Springs Family Medicine" "FSLH - St. Luke's Home Renal Dialysis" "Wayne Medical Group - Orthopedics" "NSUH LIJ Imaging at Syosset" ...
##  $ Short.Description           : chr  "HOSP-EC" "HOSP-EC" "HOSP-EC" "HOSP-EC" ...
##  $ Description                 : chr  "Hospital Extension Clinic" "Hospital Extension Clinic" "Hospital Extension Clinic" "Hospital Extension Clinic" ...
##  $ Facility.Open.Date          : chr  "08/03/2012" "08/21/2013" "06/15/2009" "02/04/2013" ...
##  $ Facility.Address.1          : chr  "165 East Union Street" "1650 Champlin Avenue" "1204 Driving Park Avenue" "100 Lafayette Drive" ...
##  $ Facility.Address.2          : chr  "" "" "" "" ...
##  $ Facility.City               : chr  "Newark" "Utica" "Newark" "Syosset" ...
##  $ Facility.State              : chr  "New York" "New York" "New York" "New York" ...
##  $ Facility.Zip.Code           : chr  "14513" "13502" "14513" "11797" ...
##  $ Facility.Phone.Number       : num  3.15e+09 3.16e+09 5.86e+09 5.17e+09 7.16e+09 ...
##  $ Facility.Fax.Number         : num  3.15e+09 3.16e+09 5.86e+09 5.17e+09 7.17e+09 ...
##  $ Facility.Website            : chr  "" "" "" "" ...
##  $ Facility.County.Code        : int  58 32 58 29 6 29 50 27 44 21 ...
##  $ Facility.County             : chr  "Wayne" "Oneida" "Wayne" "Nassau" ...
##  $ Regional.Office.ID          : int  2 3 2 7 1 7 2 2 3 3 ...
##  $ Regional.Office             : chr  "Western Regional Office - Rochester" "Central New York Regional Office" "Western Regional Office - Rochester" "Metropolitan Area Regional Office - Long Island" ...
##  $ Main.Site.Name              : chr  "Clifton Springs Hospital and Clinic" "Faxton-St Lukes Healthcare St Lukes Division" "Rochester General Hospital" "North Shore University Hospital" ...
##  $ Main.Site.Facility.ID       : int  676 599 411 541 103 490 116 411 804 3170 ...
##  $ Operating.Certificate.Number: chr  "3421000H" "3202003H" "2701003H" "2951001H" ...
##  $ Operator.Name               : chr  "Clifton Springs Sanitarium Co" "Faxton-St Lukes Healthcare" "Rochester General Hospital Inc" "North Shore University Hospital Inc" ...
##  $ Operator.Address.1          : chr  "2 Coulter Road" "1656 Champlin Avenue" "905 Culver Road" "300 Community Drive" ...
##  $ Operator.Address.2          : chr  "" "" "" "" ...
##  $ Operator.City               : chr  "Clifton Springs" "New Hartford" "Rochester" "Manhasset" ...
##  $ Operator.State              : chr  "New York" "New York" "New York" "New York" ...
##  $ Operator.Zip.Code           : chr  "14432" "13503" "14609" "11030" ...
##  $ Cooperator.Name             : chr  "Rochester Regional Health" "Mohawk Valley Health System" "Rochester Regional Health" "Northwell Healthcare, Inc." ...
##  $ Cooperator.Address          : chr  "89 Genesee Street" "1656 Champlin Ave" "89 Genesee Street" "2000 Marcus Ave." ...
##  $ Cooperator.Address.2        : chr  "" "" "" "" ...
##  $ Cooperator.City             : chr  "Rochester" "Utica" "Rochester" "New Hyde Park" ...
##  $ Cooperator.State            : chr  "New York" "New York" "New York" "New York" ...
##  $ Cooperator.Zip.Code         : int  14611 13502 14611 11042 14701 11042 14905 14611 13676 13326 ...
##  $ Ownership.Type              : chr  "Not for Profit Corporation" "Not for Profit Corporation" "Not for Profit Corporation" "Not for Profit Corporation" ...
##  $ Facility.Location           : chr  "(43.046654, -77.093529)" "(43.099613, -75.275528)" "(43.059635, -77.100792)" "(40.811646, -73.509987)" ...
##  $ geometry                    :sfc_POINT of length 100; first list element:  'XY' num  -77.1 43
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
##   ..- attr(*, "names")= chr [1:34] "Facility.ID" "Facility.Name" "Short.Description" "Description" ...

task 4: Read and process the NYS retail food stores data. Create sf objects from geographic coordinates for NYC.

# Read in the NYS retail food stores data
nyc_food_stores <- read.csv("C:/Users/melin/Documents/GTECH78520/part3/NYS_Retail_Food_Stores.csv")

# Read in the NYS retail food stores data geographic coordinates
nyc_food_stores_xy <- read.csv("C:/Users/melin/Documents/GTECH78520/part3/nys_retail_food_store_xy.csv")

# Merge data frames using the License.Number column
nyc_food_stores_df <- merge(nyc_food_stores_xy, nyc_food_stores, by = "License.Number")

# Remove row of missing data
nyc_food_stores_df <- nyc_food_stores_df[complete.cases(nyc_food_stores_df[,c("X","Y")]),]

# Create sf object from geographic coordinates
nyc_food_stores_sf <- st_as_sf(nyc_food_stores_df, coords = c("X", "Y"), crs = 4326)

# Look at the new sf object
str(nyc_food_stores_sf)
## Classes 'sf' and 'data.frame':   23972 obs. of  31 variables:
##  $ License.Number      : int  10008 10056 10057 10066 10070 10086 10090 10103 10114 10115 ...
##  $ County.x            : chr  "Albany" "Albany" "Albany" "Albany" ...
##  $ Operation.Type.x    : chr  "Store" "Store" "Store" "Store" ...
##  $ Establishment.Type.x: chr  "JAC   " "JAC   " "JAC   " "JAC   " ...
##  $ Entity.Name.x       : chr  "STEWARTS SHOPS CORP              " "STEWARTS SHOPS CORP              " "RAJA HAFEEZ URREHMAN             " "COLUCCIO DOMINICK                " ...
##  $ DBA.Name.x          : chr  "STEWARTS SHOP 105      " "STEWARTS SHOP 334      " "LATHAM FOOD MART       " "NINOS DELI&SUBS        " ...
##  $ Street.Number.x     : chr  "624" "219" "389" "718" ...
##  $ Street.Name.x       : chr  "DELAWARE AVE                 " "SAND CREEK RD                " "TROY SCHENECTADY RD          " "CENTRAL AVE            " ...
##  $ Address.Line.2.x    : logi  NA NA NA NA NA NA ...
##  $ Address.Line.3.x    : logi  NA NA NA NA NA NA ...
##  $ City.x              : chr  "DELMAR            " "ALBANY            " "LATHAM            " "ALBANY            " ...
##  $ State.x             : chr  "NY" "NY" "NY" "NY" ...
##  $ Zip.Code.x          : int  12054 12205 12110 12206 12206 12110 12205 12054 12205 12206 ...
##  $ Square.Footage.x    : chr  "2,800" "1,500" "2,000" "1,500" ...
##  $ Location.x          : chr  "624 DELAWARE AVE\nDELMAR, NY 12054\n(42.615236, -73.852119)" "219 SAND CREEK RD\nALBANY, NY 12205\n(42.697735, -73.791904)" "389 TROY SCHENECTADY RD\nLATHAM, NY 12110\n(42.745139, -73.752996)" "718 CENTRAL AVE\nALBANY, NY 12206\n(42.675991, -73.785345)" ...
##  $ Coords              : chr  "42.615236, -73.852119" "42.697735, -73.791904" "42.745139, -73.752996" "42.675991, -73.785345" ...
##  $ County.y            : chr  "Albany" "Albany" "Albany" "Albany" ...
##  $ Operation.Type.y    : chr  "Store" "Store" "Store" "Store" ...
##  $ Establishment.Type.y: chr  "JAC   " "JAC   " "JAC   " "JAC   " ...
##  $ Entity.Name.y       : chr  "STEWARTS SHOPS CORP              " "STEWARTS SHOPS CORP              " "RAJA HAFEEZ URREHMAN             " "COLUCCIO DOMINICK                " ...
##  $ DBA.Name.y          : chr  "STEWARTS SHOP 105      " "STEWARTS SHOP 334      " "LATHAM FOOD MART       " "NINOS DELI&SUBS        " ...
##  $ Street.Number.y     : chr  "624" "219" "389" "718" ...
##  $ Street.Name.y       : chr  "DELAWARE AVE                 " "SAND CREEK RD                " "TROY SCHENECTADY RD          " "CENTRAL AVE            " ...
##  $ Address.Line.2.y    : logi  NA NA NA NA NA NA ...
##  $ Address.Line.3.y    : logi  NA NA NA NA NA NA ...
##  $ City.y              : chr  "DELMAR            " "ALBANY            " "LATHAM            " "ALBANY            " ...
##  $ State.y             : chr  "NY" "NY" "NY" "NY" ...
##  $ Zip.Code.y          : int  12054 12205 12110 12206 12206 12110 12205 12054 12205 12206 ...
##  $ Square.Footage.y    : chr  "2,800" "1,500" "2,000" "1,500" ...
##  $ Location.y          : chr  "624 DELAWARE AVE\nDELMAR, NY 12054\n(42.615236, -73.852119)" "219 SAND CREEK RD\nALBANY, NY 12205\n(42.697735, -73.791904)" "389 TROY SCHENECTADY RD\nLATHAM, NY 12110\n(42.745139, -73.752996)" "718 CENTRAL AVE\nALBANY, NY 12206\n(42.675991, -73.785345)" ...
##  $ geometry            :sfc_POINT of length 23972; first list element:  'XY' num  -73.9 42.6
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
##   ..- attr(*, "names")= chr [1:30] "License.Number" "County.x" "Operation.Type.x" "Establishment.Type.x" ...
#Create sf objects from geographic coordinates for NYC.

# First project to same CRS as the NYC postal areas data
nyc_food_stores_sf <- st_transform(nyc_food_stores_sf, st_crs(nyc_postal_areas_sf))

# Only keep points that fall within the NYC postal areas polygon
nyc_food_stores_sf2 <- st_intersection(nyc_food_stores_sf, nyc_postal_areas_sf)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
# Look at the new sf object
str(nyc_food_stores_sf2)
## Classes 'sf' and 'data.frame':   11323 obs. of  43 variables:
##  $ License.Number      : int  702552 706547 720623 610241 610651 611047 611677 611864 611960 612241 ...
##  $ County.x            : chr  "Queens" "Queens" "Queens" "Kings" ...
##  $ Operation.Type.x    : chr  "Store" "Store" "Store" "Store" ...
##  $ Establishment.Type.x: chr  "JAC   " "JAC   " "JAC   " "A     " ...
##  $ Entity.Name.x       : chr  "ALSAMET FOOD CORP                " "HUQAIS SHUAIB M                  " "142 BEST SUPER DELI INC          " "RITE AID OF NEW YORK INC         " ...
##  $ DBA.Name.x          : chr  "ALSAMET FOOD           " "KING OF ROCKAWAY DELI &" "142 BEST SUPER DELI    " "RITE AID 4271          " ...
##  $ Street.Number.x     : chr  "14702" "14221" "14134" "1040" ...
##  $ Street.Name.x       : chr  "ROCKAWAY BLVD              " "ROCKAWAY BLVD              " "ROCKAWAY BLVD              " "ST JOHNS PLACE              " ...
##  $ Address.Line.2.x    : logi  NA NA NA NA NA NA ...
##  $ Address.Line.3.x    : logi  NA NA NA NA NA NA ...
##  $ City.x              : chr  "JAMAICA           " "JAMAICA           " "JAMAICA           " "BROOKLYN          " ...
##  $ State.x             : chr  "NY" "NY" "NY" "NY" ...
##  $ Zip.Code.x          : int  11436 11436 11436 11213 11213 11213 11213 11213 11213 11213 ...
##  $ Square.Footage.x    : chr  "2,000" "2,000" "0" "8,000" ...
##  $ Location.x          : chr  "14702 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.673409, -73.790643)" "14221 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.674048, -73.798135)" "14134 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.674097, -73.798598)" "1040 ST JOHNS PLACE\nBROOKLYN, NY 11213\n(40.671268, -73.943582)" ...
##  $ Coords              : chr  "40.673409, -73.790643" "40.674048, -73.798135" "40.674097, -73.798598" "40.671268, -73.943582" ...
##  $ County.y            : chr  "Queens" "Queens" "Queens" "Kings" ...
##  $ Operation.Type.y    : chr  "Store" "Store" "Store" "Store" ...
##  $ Establishment.Type.y: chr  "JAC   " "JAC   " "JAC   " "A     " ...
##  $ Entity.Name.y       : chr  "ALSAMET FOOD CORP                " "HUQAIS SHUAIB M                  " "142 BEST SUPER DELI INC          " "RITE AID OF NEW YORK INC         " ...
##  $ DBA.Name.y          : chr  "ALSAMET FOOD           " "KING OF ROCKAWAY DELI &" "142 BEST SUPER DELI    " "RITE AID 4271          " ...
##  $ Street.Number.y     : chr  "14702" "14221" "14134" "1040" ...
##  $ Street.Name.y       : chr  "ROCKAWAY BLVD              " "ROCKAWAY BLVD              " "ROCKAWAY BLVD              " "ST JOHNS PLACE              " ...
##  $ Address.Line.2.y    : logi  NA NA NA NA NA NA ...
##  $ Address.Line.3.y    : logi  NA NA NA NA NA NA ...
##  $ City.y              : chr  "JAMAICA           " "JAMAICA           " "JAMAICA           " "BROOKLYN          " ...
##  $ State.y             : chr  "NY" "NY" "NY" "NY" ...
##  $ Zip.Code.y          : int  11436 11436 11436 11213 11213 11213 11213 11213 11213 11213 ...
##  $ Square.Footage.y    : chr  "2,000" "2,000" "0" "8,000" ...
##  $ Location.y          : chr  "14702 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.673409, -73.790643)" "14221 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.674048, -73.798135)" "14134 ROCKAWAY BLVD\nJAMAICA, NY 11436\n(40.674097, -73.798598)" "1040 ST JOHNS PLACE\nBROOKLYN, NY 11213\n(40.671268, -73.943582)" ...
##  $ ZIPCODE             : chr  "11436" "11436" "11436" "11213" ...
##  $ BLDGZIP             : chr  "0" "0" "0" "0" ...
##  $ PO_NAME             : chr  "Jamaica" "Jamaica" "Jamaica" "Brooklyn" ...
##  $ POPULATION          : num  18681 18681 18681 62426 62426 ...
##  $ AREA                : num  22699295 22699295 22699295 29631004 29631004 ...
##  $ STATE               : chr  "NY" "NY" "NY" "NY" ...
##  $ COUNTY              : chr  "Queens" "Queens" "Queens" "Kings" ...
##  $ ST_FIPS             : chr  "36" "36" "36" "36" ...
##  $ CTY_FIPS            : chr  "081" "081" "081" "047" ...
##  $ URL                 : chr  "http://www.usps.com/" "http://www.usps.com/" "http://www.usps.com/" "http://www.usps.com/" ...
##  $ SHAPE_AREA          : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ SHAPE_LEN           : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ geometry            :sfc_POINT of length 11323; first list element:  'XY' num  1042324 184687
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
##   ..- attr(*, "names")= chr [1:42] "License.Number" "County.x" "Operation.Type.x" "Establishment.Type.x" ...

task 5:Use simple mapping method, either based on ggmap+ggplot or mapview, with a basemap to verify the above datasets in terms of their geometry locations.

# Display the NYC postal areas using mapview
mapview(nyc_postal_areas_sf, zcol = "ZIPCODE", legend = FALSE)
# Display the NYS health facilities 
mapview(health_facilities_sf, zcol = "Facility.Name", legend = FALSE)
# Display the NYS food stores for NYC
mapview(nyc_food_stores_sf2, zcol = "License.Number", legend = FALSE)

task 6:Save the three sf objects in a RData file or in a single GeoPackage file/database.

# Save data to RData file
save(nyc_postal_areas_sf, health_facilities_sf, nyc_food_stores_sf,
     file = 'C:/Users/melin/Documents/GTECH78520/part3/assignment1_sf.RData')