R Spatial Lab Assignment #2

Task 0: Set Up New Project and Load Week 7 Saved Data

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.0     ✔ readr     2.1.6
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.4, PROJ 9.7.0; sf_use_s2() is TRUE
library(mapview)
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
wd <- getwd() #Get working directory 

data_dir <- file.path(wd,"data1") #Set up file path

list.files("data1") #See what data files in the data1 folder
##  [1] "2010 Census Tracts.zip"                                     
##  [2] "ACSDP5Y2018.DP05_data_with_overlays_2020-04-22T132935.csv"  
##  [3] "ACSDP5Y2018.DP05_metadata_2020-04-22T132935.csv"            
##  [4] "ACSDP5Y2018.DP05_table_title_2020-04-22T132935.txt"         
##  [5] "geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.dbf"        
##  [6] "geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.prj"        
##  [7] "geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.shp"        
##  [8] "geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.shx"        
##  [9] "nyc_data.gpkg"                                              
## [10] "nycFoodStore.dbf"                                           
## [11] "nycFoodStore.prj"                                           
## [12] "nycFoodStore.shp"                                           
## [13] "nycFoodStore.shx"                                           
## [14] "NYS_Health_Facility.csv"                                    
## [15] "NYSDAM_RetailFoodStores_DataDictionary.pdf"                 
## [16] "NYSDAM_RetailFoodStores_Overview.pdf"                       
## [17] "NYSDAM_RetailFoodStoresEstablishmentTypeCodes.pdf"          
## [18] "NYSDOH_HealthFacilityGeneralInformation_data_dictionary.pdf"
## [19] "NYSDOH_HealthFacilityGeneralInformation_overview.pdf"       
## [20] "tests-by-zcta_2020_04_12.csv"                               
## [21] "tests-by-zcta_2020_04_19.csv"                               
## [22] "tests-by-zcta_2021_04_23.csv"
nyc_zip <- st_read("data1/nyc_data.gpkg", layer="zip") #Load each of the data files saved
## Reading layer `zip' from data source 
##   `C:\Users\wildk\OneDrive\Documents\2026 Spring\Visual in R\R-Spatial-Week 8\data1\nyc_data.gpkg' 
##   using driver `GPKG'
## 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)
food_retial <- st_read("data1/nyc_data.gpkg", layer="food")
## Reading layer `food' from data source 
##   `C:\Users\wildk\OneDrive\Documents\2026 Spring\Visual in R\R-Spatial-Week 8\data1\nyc_data.gpkg' 
##   using driver `GPKG'
## Simple feature collection with 11300 features and 16 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -74.2484 ymin: 40.50782 xmax: -73.67061 ymax: 40.91008
## Geodetic CRS:  WGS 84
health_fac <- st_read("data1/nyc_data.gpkg", layer="health")
## Reading layer `health' from data source 
##   `C:\Users\wildk\OneDrive\Documents\2026 Spring\Visual in R\R-Spatial-Week 8\data1\nyc_data.gpkg' 
##   using driver `GPKG'
## Simple feature collection with 3848 features and 34 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -79.6299 ymin: -75.45935 xmax: 43.21162 ymax: 44.97849
## Geodetic CRS:  WGS 84
unzip(file.path(data_dir,"2010 Census Tracts.zip"),
      exdir=data_dir) #Up zip files from 2010 Census Tracts.zip
tracts_2010 <- st_read(file.path(data_dir, 
                                 "geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a.shp")) #Read 2010 tract data for later
## Reading layer `geo_export_1dc7b645-647b-4806-b9a0-7b79660f120a' from data source `C:\Users\wildk\OneDrive\Documents\2026 Spring\Visual in R\R-Spatial-Week 8\data1\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)

Task 1: Join COVID-19 Data to NYC Zip Codes

covid <- read_csv(file.path(data_dir, "tests-by-zcta_2020_04_19.csv")) #Read csv file for COVID-19 data
## Rows: 178 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (4): MODZCTA, Positive, Total, zcta_cum.perc_pos
## 
## ℹ 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.
colnames(covid) #Identifying the names of the columns
## [1] "MODZCTA"           "Positive"          "Total"            
## [4] "zcta_cum.perc_pos"
#Look at the data types for ZIPCODE and MODZCTA
str(nyc_zip$ZIPCODE) 
##  chr [1:263] "11436" "11213" "11212" "11225" "11218" "11226" "11219" ...
str(covid$MODZCTA)
##  num [1:178] NA 10001 10002 10003 10004 ...
covid <- covid %>%
  mutate(MODZCTA = as.character(MODZCTA)) #Converts MODZCTA from number to character

zip_covid <- nyc_zip %>%
  left_join(covid, by = c("ZIPCODE" = "MODZCTA")) #Run spatial join

Task 2: Aggregate NYC Food Retails data to NYC Zip code data

colnames(food_retial) #Identifying the names of the columns
##  [1] "i_county"           "license_number"     "operation_type"    
##  [4] "establishment_type" "entity_name"        "dba_name"          
##  [7] "street_number"      "street_name"        "address_line_2"    
## [10] "address_line_3"     "city"               "state"             
## [13] "zip_code"           "square_footage"     "location"          
## [16] "coords"             "geom"
table(food_retial$establishment_type) #Identify the different combinations using the data dictionary provided
## 
##      A    JAB   JABC  JABCD JABCDH JABCDK  JABCH JABCHK  JABCK   JABH  JABHK 
##   2289      5    224      3      1      1     54     11     18     22      6 
##   JABK    JAC   JACD  JACDE  JACDH JACDHK  JACDK   JACG   JACH  JACHK   JACK 
##      5   8457     45      2      3     13     13      1     36     12     46 
##   JACZ    JAD  JADHK   JADK   JADO   JAHK    JAK    JAZ    JDA    JKA 
##      1     11      2     13      1      1      1      1      1      1
zip_food <- food_retial %>%
  mutate(establishment_type = trimws(establishment_type)) %>% #Clean out empty spaces within establishment_types
  filter(str_detect(establishment_type, "^(A|B|J)")) %>% #Filtering out establishment type with A (retails stores), B (bakeries) and J (multiple operations)
  st_transform(st_crs(zip_covid)) %>% #Transform to sf
  st_join(zip_covid, ., join = st_contains) %>%  #Spatial Join
  group_by(ZIPCODE) %>% #Aggregation
  summarise(
    food_store_count = n(),
    Positive = first(Positive),
    Total = first(Total)
  )

Task 3: Aggregate NYC Health Facilities data to NYC Zip code data

colnames(health_fac) #Identifying the names of the columns
##  [1] "facility_id"                  "facility_name"               
##  [3] "short_description"            "description"                 
##  [5] "facility_open_date"           "facility_address_1"          
##  [7] "facility_address_2"           "facility_city"               
##  [9] "facility_state"               "facility_zip_code"           
## [11] "facility_phone_number"        "facility_fax_number"         
## [13] "facility_website"             "facility_county_code"        
## [15] "facility_county"              "regional_office_id"          
## [17] "regional_office"              "main_site_name"              
## [19] "main_site_facility_id"        "operating_certificate_number"
## [21] "operator_name"                "operator_address_1"          
## [23] "operator_address_2"           "operator_city"               
## [25] "operator_state"               "operator_zip_code"           
## [27] "cooperator_name"              "cooperator_address"          
## [29] "cooperator_address_2"         "cooperator_city"             
## [31] "cooperator_state"             "cooperator_zip_code"         
## [33] "ownership_type"               "facility_location"           
## [35] "geom"
zip_health <- health_fac %>%
  filter(description == "Diagnostic and Treatment Center") %>% #Filter out Diagnostic and Treatment Center data
  st_transform(st_crs(nyc_zip)) %>% #Transform to sf
  st_join(zip_food, ., join = st_contains) %>% #Spatial Join
  group_by(ZIPCODE) %>% #Aggregation
  summarise(
    food_store_count = first(food_store_count),
    health_count = n(),
    Positive = first(Positive),
    Total = first(Total)
  )

Task 4: Join Census ACS data to NYC Planning Census Tract data

acs <- read_csv(
  file.path(data_dir, "ACSDP5Y2018.DP05_data_with_overlays_2020-04-22T132935.csv"),
  skip = 1
) # Read ACS data
## New names:
## Rows: 2167 Columns: 358
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (181): id, Geographic Area Name, Percent Margin of Error!!SEX AND AGE!!T... dbl
## (177): Estimate!!RACE!!Total population, Margin of Error!!RACE!!Total po...
## ℹ 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.
## • `Estimate!!RACE!!Total population!!One race` -> `Estimate!!RACE!!Total
##   population!!One race...12`
## • `Margin of Error!!RACE!!Total population!!One race` -> `Margin of
##   Error!!RACE!!Total population!!One race...13`
## • `Percent Estimate!!RACE!!Total population!!One race` -> `Percent
##   Estimate!!RACE!!Total population!!One race...14`
## • `Percent Margin of Error!!RACE!!Total population!!One race` -> `Percent
##   Margin of Error!!RACE!!Total population!!One race...15`
## • `Estimate!!RACE!!Total population!!Two or more races` ->
##   `Estimate!!RACE!!Total population!!Two or more races...16`
## • `Margin of Error!!RACE!!Total population!!Two or more races` -> `Margin of
##   Error!!RACE!!Total population!!Two or more races...17`
## • `Percent Estimate!!RACE!!Total population!!Two or more races` -> `Percent
##   Estimate!!RACE!!Total population!!Two or more races...18`
## • `Percent Margin of Error!!RACE!!Total population!!Two or more races` ->
##   `Percent Margin of Error!!RACE!!Total population!!Two or more races...19`
## • `Estimate!!RACE!!Total population!!One race` -> `Estimate!!RACE!!Total
##   population!!One race...20`
## • `Margin of Error!!RACE!!Total population!!One race` -> `Margin of
##   Error!!RACE!!Total population!!One race...21`
## • `Percent Estimate!!RACE!!Total population!!One race` -> `Percent
##   Estimate!!RACE!!Total population!!One race...22`
## • `Percent Margin of Error!!RACE!!Total population!!One race` -> `Percent
##   Margin of Error!!RACE!!Total population!!One race...23`
## • `Estimate!!RACE!!Total population!!Two or more races` ->
##   `Estimate!!RACE!!Total population!!Two or more races...108`
## • `Margin of Error!!RACE!!Total population!!Two or more races` -> `Margin of
##   Error!!RACE!!Total population!!Two or more races...109`
## • `Percent Estimate!!RACE!!Total population!!Two or more races` -> `Percent
##   Estimate!!RACE!!Total population!!Two or more races...110`
## • `Percent Margin of Error!!RACE!!Total population!!Two or more races` ->
##   `Percent Margin of Error!!RACE!!Total population!!Two or more races...111`
## • `Estimate!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Estimate!!SEX AND AGE!!Total population!!18 years and over...316`
## • `Margin of Error!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Margin of Error!!SEX AND AGE!!Total population!!18 years and over...317`
## • `Percent Estimate!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Percent Estimate!!SEX AND AGE!!Total population!!18 years and over...318`
## • `Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over`
##   -> `Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and
##   over...319`
## • `Estimate!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Estimate!!SEX AND AGE!!Total population!!65 years and over...328`
## • `Margin of Error!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Margin of Error!!SEX AND AGE!!Total population!!65 years and over...329`
## • `Percent Estimate!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Percent Estimate!!SEX AND AGE!!Total population!!65 years and over...330`
## • `Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over`
##   -> `Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and
##   over...331`
## • `Estimate!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Estimate!!SEX AND AGE!!Total population!!18 years and over...332`
## • `Margin of Error!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Margin of Error!!SEX AND AGE!!Total population!!18 years and over...333`
## • `Percent Estimate!!SEX AND AGE!!Total population!!18 years and over` ->
##   `Percent Estimate!!SEX AND AGE!!Total population!!18 years and over...334`
## • `Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over`
##   -> `Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and
##   over...335`
## • `Estimate!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Estimate!!SEX AND AGE!!Total population!!65 years and over...348`
## • `Margin of Error!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Margin of Error!!SEX AND AGE!!Total population!!65 years and over...349`
## • `Percent Estimate!!SEX AND AGE!!Total population!!65 years and over` ->
##   `Percent Estimate!!SEX AND AGE!!Total population!!65 years and over...350`
## • `Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over`
##   -> `Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and
##   over...351`
colnames(acs) #Identifying the names of the columns
##   [1] "id"                                                                                                                                                                             
##   [2] "Geographic Area Name"                                                                                                                                                           
##   [3] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Female"                                                                                              
##   [4] "Estimate!!SEX AND AGE!!Total population!!65 years and over!!Sex ratio (males per 100 females)"                                                                                  
##   [5] "Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Sex ratio (males per 100 females)"                                                                           
##   [6] "Percent Estimate!!SEX AND AGE!!Total population!!65 years and over!!Sex ratio (males per 100 females)"                                                                          
##   [7] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Sex ratio (males per 100 females)"                                                                   
##   [8] "Estimate!!RACE!!Total population"                                                                                                                                               
##   [9] "Margin of Error!!RACE!!Total population"                                                                                                                                        
##  [10] "Percent Estimate!!RACE!!Total population"                                                                                                                                       
##  [11] "Percent Margin of Error!!RACE!!Total population"                                                                                                                                
##  [12] "Estimate!!RACE!!Total population!!One race...12"                                                                                                                                
##  [13] "Margin of Error!!RACE!!Total population!!One race...13"                                                                                                                         
##  [14] "Percent Estimate!!RACE!!Total population!!One race...14"                                                                                                                        
##  [15] "Percent Margin of Error!!RACE!!Total population!!One race...15"                                                                                                                 
##  [16] "Estimate!!RACE!!Total population!!Two or more races...16"                                                                                                                       
##  [17] "Margin of Error!!RACE!!Total population!!Two or more races...17"                                                                                                                
##  [18] "Percent Estimate!!RACE!!Total population!!Two or more races...18"                                                                                                               
##  [19] "Percent Margin of Error!!RACE!!Total population!!Two or more races...19"                                                                                                        
##  [20] "Estimate!!RACE!!Total population!!One race...20"                                                                                                                                
##  [21] "Margin of Error!!RACE!!Total population!!One race...21"                                                                                                                         
##  [22] "Percent Estimate!!RACE!!Total population!!One race...22"                                                                                                                        
##  [23] "Percent Margin of Error!!RACE!!Total population!!One race...23"                                                                                                                 
##  [24] "Estimate!!RACE!!Total population!!One race!!White"                                                                                                                              
##  [25] "Margin of Error!!RACE!!Total population!!One race!!White"                                                                                                                       
##  [26] "Percent Estimate!!RACE!!Total population!!One race!!White"                                                                                                                      
##  [27] "Percent Margin of Error!!RACE!!Total population!!One race!!White"                                                                                                               
##  [28] "Estimate!!RACE!!Total population!!One race!!Black or African American"                                                                                                          
##  [29] "Margin of Error!!RACE!!Total population!!One race!!Black or African American"                                                                                                   
##  [30] "Percent Estimate!!RACE!!Total population!!One race!!Black or African American"                                                                                                  
##  [31] "Percent Margin of Error!!RACE!!Total population!!One race!!Black or African American"                                                                                           
##  [32] "Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native"                                                                                                  
##  [33] "Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native"                                                                                           
##  [34] "Percent Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native"                                                                                          
##  [35] "Percent Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native"                                                                                   
##  [36] "Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Cherokee tribal grouping"                                                                        
##  [37] "Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Cherokee tribal grouping"                                                                 
##  [38] "Percent Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Cherokee tribal grouping"                                                                
##  [39] "Percent Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Cherokee tribal grouping"                                                         
##  [40] "Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Chippewa tribal grouping"                                                                        
##  [41] "Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Chippewa tribal grouping"                                                                 
##  [42] "Percent Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Chippewa tribal grouping"                                                                
##  [43] "Percent Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Chippewa tribal grouping"                                                         
##  [44] "Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Navajo tribal grouping"                                                                          
##  [45] "Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Navajo tribal grouping"                                                                   
##  [46] "Percent Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Navajo tribal grouping"                                                                  
##  [47] "Percent Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Navajo tribal grouping"                                                           
##  [48] "Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Sioux tribal grouping"                                                                           
##  [49] "Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Sioux tribal grouping"                                                                    
##  [50] "Percent Estimate!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Sioux tribal grouping"                                                                   
##  [51] "Percent Margin of Error!!RACE!!Total population!!One race!!American Indian and Alaska Native!!Sioux tribal grouping"                                                            
##  [52] "Estimate!!RACE!!Total population!!One race!!Asian"                                                                                                                              
##  [53] "Margin of Error!!RACE!!Total population!!One race!!Asian"                                                                                                                       
##  [54] "Percent Estimate!!RACE!!Total population!!One race!!Asian"                                                                                                                      
##  [55] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian"                                                                                                               
##  [56] "Estimate!!RACE!!Total population!!One race!!Asian!!Asian Indian"                                                                                                                
##  [57] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Asian Indian"                                                                                                         
##  [58] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Asian Indian"                                                                                                        
##  [59] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Asian Indian"                                                                                                 
##  [60] "Estimate!!RACE!!Total population!!One race!!Asian!!Chinese"                                                                                                                     
##  [61] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Chinese"                                                                                                              
##  [62] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Chinese"                                                                                                             
##  [63] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Chinese"                                                                                                      
##  [64] "Estimate!!RACE!!Total population!!One race!!Asian!!Filipino"                                                                                                                    
##  [65] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Filipino"                                                                                                             
##  [66] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Filipino"                                                                                                            
##  [67] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Filipino"                                                                                                     
##  [68] "Estimate!!RACE!!Total population!!One race!!Asian!!Japanese"                                                                                                                    
##  [69] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Japanese"                                                                                                             
##  [70] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Japanese"                                                                                                            
##  [71] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Japanese"                                                                                                     
##  [72] "Estimate!!RACE!!Total population!!One race!!Asian!!Korean"                                                                                                                      
##  [73] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Korean"                                                                                                               
##  [74] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Korean"                                                                                                              
##  [75] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Korean"                                                                                                       
##  [76] "Estimate!!RACE!!Total population!!One race!!Asian!!Vietnamese"                                                                                                                  
##  [77] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Vietnamese"                                                                                                           
##  [78] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Vietnamese"                                                                                                          
##  [79] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Vietnamese"                                                                                                   
##  [80] "Estimate!!RACE!!Total population!!One race!!Asian!!Other Asian"                                                                                                                 
##  [81] "Margin of Error!!RACE!!Total population!!One race!!Asian!!Other Asian"                                                                                                          
##  [82] "Percent Estimate!!RACE!!Total population!!One race!!Asian!!Other Asian"                                                                                                         
##  [83] "Percent Margin of Error!!RACE!!Total population!!One race!!Asian!!Other Asian"                                                                                                  
##  [84] "Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander"                                                                                         
##  [85] "Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander"                                                                                  
##  [86] "Percent Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander"                                                                                 
##  [87] "Percent Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander"                                                                          
##  [88] "Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Native Hawaiian"                                                                        
##  [89] "Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Native Hawaiian"                                                                 
##  [90] "Percent Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Native Hawaiian"                                                                
##  [91] "Percent Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Native Hawaiian"                                                         
##  [92] "Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Guamanian or Chamorro"                                                                  
##  [93] "Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Guamanian or Chamorro"                                                           
##  [94] "Percent Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Guamanian or Chamorro"                                                          
##  [95] "Percent Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Guamanian or Chamorro"                                                   
##  [96] "Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Samoan"                                                                                 
##  [97] "Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Samoan"                                                                          
##  [98] "Percent Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Samoan"                                                                         
##  [99] "Percent Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Samoan"                                                                  
## [100] "Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Other Pacific Islander"                                                                 
## [101] "Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Other Pacific Islander"                                                          
## [102] "Percent Estimate!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Other Pacific Islander"                                                         
## [103] "Percent Margin of Error!!RACE!!Total population!!One race!!Native Hawaiian and Other Pacific Islander!!Other Pacific Islander"                                                  
## [104] "Estimate!!RACE!!Total population!!One race!!Some other race"                                                                                                                    
## [105] "Margin of Error!!RACE!!Total population!!One race!!Some other race"                                                                                                             
## [106] "Percent Estimate!!RACE!!Total population!!One race!!Some other race"                                                                                                            
## [107] "Percent Margin of Error!!RACE!!Total population!!One race!!Some other race"                                                                                                     
## [108] "Estimate!!RACE!!Total population!!Two or more races...108"                                                                                                                      
## [109] "Margin of Error!!RACE!!Total population!!Two or more races...109"                                                                                                               
## [110] "Percent Estimate!!RACE!!Total population!!Two or more races...110"                                                                                                              
## [111] "Percent Margin of Error!!RACE!!Total population!!Two or more races...111"                                                                                                       
## [112] "Estimate!!RACE!!Total population!!Two or more races!!White and Black or African American"                                                                                       
## [113] "Margin of Error!!RACE!!Total population!!Two or more races!!White and Black or African American"                                                                                
## [114] "Percent Estimate!!RACE!!Total population!!Two or more races!!White and Black or African American"                                                                               
## [115] "Percent Margin of Error!!RACE!!Total population!!Two or more races!!White and Black or African American"                                                                        
## [116] "Estimate!!RACE!!Total population!!Two or more races!!White and American Indian and Alaska Native"                                                                               
## [117] "Margin of Error!!RACE!!Total population!!Two or more races!!White and American Indian and Alaska Native"                                                                        
## [118] "Percent Estimate!!RACE!!Total population!!Two or more races!!White and American Indian and Alaska Native"                                                                       
## [119] "Percent Margin of Error!!RACE!!Total population!!Two or more races!!White and American Indian and Alaska Native"                                                                
## [120] "Estimate!!RACE!!Total population!!Two or more races!!White and Asian"                                                                                                           
## [121] "Margin of Error!!RACE!!Total population!!Two or more races!!White and Asian"                                                                                                    
## [122] "Percent Estimate!!RACE!!Total population!!Two or more races!!White and Asian"                                                                                                   
## [123] "Percent Margin of Error!!RACE!!Total population!!Two or more races!!White and Asian"                                                                                            
## [124] "Estimate!!RACE!!Total population!!Two or more races!!Black or African American and American Indian and Alaska Native"                                                           
## [125] "Margin of Error!!RACE!!Total population!!Two or more races!!Black or African American and American Indian and Alaska Native"                                                    
## [126] "Percent Estimate!!RACE!!Total population!!Two or more races!!Black or African American and American Indian and Alaska Native"                                                   
## [127] "Percent Margin of Error!!RACE!!Total population!!Two or more races!!Black or African American and American Indian and Alaska Native"                                            
## [128] "Estimate!!Race alone or in combination with one or more other races!!Total population"                                                                                          
## [129] "Margin of Error!!Race alone or in combination with one or more other races!!Total population"                                                                                   
## [130] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population"                                                                                  
## [131] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population"                                                                           
## [132] "Estimate!!Race alone or in combination with one or more other races!!Total population!!White"                                                                                   
## [133] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!White"                                                                            
## [134] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!White"                                                                           
## [135] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!White"                                                                    
## [136] "Estimate!!Race alone or in combination with one or more other races!!Total population!!Black or African American"                                                               
## [137] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Black or African American"                                                        
## [138] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!Black or African American"                                                       
## [139] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Black or African American"                                                
## [140] "Estimate!!Race alone or in combination with one or more other races!!Total population!!American Indian and Alaska Native"                                                       
## [141] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!American Indian and Alaska Native"                                                
## [142] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!American Indian and Alaska Native"                                               
## [143] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!American Indian and Alaska Native"                                        
## [144] "Estimate!!Race alone or in combination with one or more other races!!Total population!!Asian"                                                                                   
## [145] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Asian"                                                                            
## [146] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!Asian"                                                                           
## [147] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Asian"                                                                    
## [148] "Estimate!!Race alone or in combination with one or more other races!!Total population!!Native Hawaiian and Other Pacific Islander"                                              
## [149] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Native Hawaiian and Other Pacific Islander"                                       
## [150] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!Native Hawaiian and Other Pacific Islander"                                      
## [151] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Native Hawaiian and Other Pacific Islander"                               
## [152] "Estimate!!Race alone or in combination with one or more other races!!Total population!!Some other race"                                                                         
## [153] "Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Some other race"                                                                  
## [154] "Percent Estimate!!Race alone or in combination with one or more other races!!Total population!!Some other race"                                                                 
## [155] "Percent Margin of Error!!Race alone or in combination with one or more other races!!Total population!!Some other race"                                                          
## [156] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population"                                                                                                                        
## [157] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population"                                                                                                                 
## [158] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population"                                                                                                                
## [159] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population"                                                                                                         
## [160] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"                                                                                      
## [161] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"                                                                               
## [162] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"                                                                              
## [163] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"                                                                       
## [164] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Mexican"                                                                             
## [165] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Mexican"                                                                      
## [166] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Mexican"                                                                     
## [167] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Mexican"                                                              
## [168] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Puerto Rican"                                                                        
## [169] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Puerto Rican"                                                                 
## [170] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Puerto Rican"                                                                
## [171] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Puerto Rican"                                                         
## [172] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Cuban"                                                                               
## [173] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Cuban"                                                                        
## [174] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Cuban"                                                                       
## [175] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Cuban"                                                                
## [176] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Other Hispanic or Latino"                                                            
## [177] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Other Hispanic or Latino"                                                     
## [178] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Other Hispanic or Latino"                                                    
## [179] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)!!Other Hispanic or Latino"                                             
## [180] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino"                                                                                                
## [181] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino"                                                                                         
## [182] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino"                                                                                        
## [183] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino"                                                                                 
## [184] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!White alone"                                                                                   
## [185] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!White alone"                                                                            
## [186] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!White alone"                                                                           
## [187] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!White alone"                                                                    
## [188] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Black or African American alone"                                                               
## [189] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Black or African American alone"                                                        
## [190] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Black or African American alone"                                                       
## [191] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Black or African American alone"                                                
## [192] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!American Indian and Alaska Native alone"                                                       
## [193] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!American Indian and Alaska Native alone"                                                
## [194] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!American Indian and Alaska Native alone"                                               
## [195] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!American Indian and Alaska Native alone"                                        
## [196] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Asian alone"                                                                                   
## [197] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Asian alone"                                                                            
## [198] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Asian alone"                                                                           
## [199] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Asian alone"                                                                    
## [200] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Native Hawaiian and Other Pacific Islander alone"                                              
## [201] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Native Hawaiian and Other Pacific Islander alone"                                       
## [202] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Native Hawaiian and Other Pacific Islander alone"                                      
## [203] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Native Hawaiian and Other Pacific Islander alone"                               
## [204] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Some other race alone"                                                                         
## [205] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Some other race alone"                                                                  
## [206] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Some other race alone"                                                                 
## [207] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Some other race alone"                                                          
## [208] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races"                                                                             
## [209] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races"                                                                      
## [210] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races"                                                                     
## [211] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races"                                                              
## [212] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races including Some other race"                                        
## [213] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races including Some other race"                                 
## [214] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races including Some other race"                                
## [215] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races including Some other race"                         
## [216] "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races excluding Some other race, and Three or more races"               
## [217] "Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races excluding Some other race, and Three or more races"        
## [218] "Percent Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races excluding Some other race, and Three or more races"       
## [219] "Percent Margin of Error!!HISPANIC OR LATINO AND RACE!!Total population!!Not Hispanic or Latino!!Two or more races!!Two races excluding Some other race, and Three or more races"
## [220] "Estimate!!Total housing units"                                                                                                                                                  
## [221] "Margin of Error!!Total housing units"                                                                                                                                           
## [222] "Percent Estimate!!Total housing units"                                                                                                                                          
## [223] "Percent Margin of Error!!Total housing units"                                                                                                                                   
## [224] "Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population"                                                                                                      
## [225] "Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population"                                                                                               
## [226] "Percent Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population"                                                                                              
## [227] "Percent Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population"                                                                                       
## [228] "Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Male"                                                                                                
## [229] "Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Male"                                                                                         
## [230] "Percent Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Male"                                                                                        
## [231] "Percent Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Male"                                                                                 
## [232] "Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Female"                                                                                              
## [233] "Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Female"                                                                                       
## [234] "Percent Estimate!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Female"                                                                                      
## [235] "Percent Margin of Error!!CITIZEN, VOTING AGE POPULATION!!Citizen, 18 and over population!!Female"                                                                               
## [236] "Estimate!!SEX AND AGE!!Total population"                                                                                                                                        
## [237] "Margin of Error!!SEX AND AGE!!Total population"                                                                                                                                 
## [238] "Percent Estimate!!SEX AND AGE!!Total population"                                                                                                                                
## [239] "Percent Margin of Error!!SEX AND AGE!!Total population"                                                                                                                         
## [240] "Estimate!!SEX AND AGE!!Total population!!Male"                                                                                                                                  
## [241] "Margin of Error!!SEX AND AGE!!Total population!!Male"                                                                                                                           
## [242] "Percent Estimate!!SEX AND AGE!!Total population!!Male"                                                                                                                          
## [243] "Percent Margin of Error!!SEX AND AGE!!Total population!!Male"                                                                                                                   
## [244] "Estimate!!SEX AND AGE!!Total population!!Female"                                                                                                                                
## [245] "Margin of Error!!SEX AND AGE!!Total population!!Female"                                                                                                                         
## [246] "Percent Estimate!!SEX AND AGE!!Total population!!Female"                                                                                                                        
## [247] "Percent Margin of Error!!SEX AND AGE!!Total population!!Female"                                                                                                                 
## [248] "Estimate!!SEX AND AGE!!Total population!!Sex ratio (males per 100 females)"                                                                                                     
## [249] "Margin of Error!!SEX AND AGE!!Total population!!Sex ratio (males per 100 females)"                                                                                              
## [250] "Percent Estimate!!SEX AND AGE!!Total population!!Sex ratio (males per 100 females)"                                                                                             
## [251] "Percent Margin of Error!!SEX AND AGE!!Total population!!Sex ratio (males per 100 females)"                                                                                      
## [252] "Estimate!!SEX AND AGE!!Total population!!Under 5 years"                                                                                                                         
## [253] "Margin of Error!!SEX AND AGE!!Total population!!Under 5 years"                                                                                                                  
## [254] "Percent Estimate!!SEX AND AGE!!Total population!!Under 5 years"                                                                                                                 
## [255] "Percent Margin of Error!!SEX AND AGE!!Total population!!Under 5 years"                                                                                                          
## [256] "Estimate!!SEX AND AGE!!Total population!!5 to 9 years"                                                                                                                          
## [257] "Margin of Error!!SEX AND AGE!!Total population!!5 to 9 years"                                                                                                                   
## [258] "Percent Estimate!!SEX AND AGE!!Total population!!5 to 9 years"                                                                                                                  
## [259] "Percent Margin of Error!!SEX AND AGE!!Total population!!5 to 9 years"                                                                                                           
## [260] "Estimate!!SEX AND AGE!!Total population!!10 to 14 years"                                                                                                                        
## [261] "Margin of Error!!SEX AND AGE!!Total population!!10 to 14 years"                                                                                                                 
## [262] "Percent Estimate!!SEX AND AGE!!Total population!!10 to 14 years"                                                                                                                
## [263] "Percent Margin of Error!!SEX AND AGE!!Total population!!10 to 14 years"                                                                                                         
## [264] "Estimate!!SEX AND AGE!!Total population!!15 to 19 years"                                                                                                                        
## [265] "Margin of Error!!SEX AND AGE!!Total population!!15 to 19 years"                                                                                                                 
## [266] "Percent Estimate!!SEX AND AGE!!Total population!!15 to 19 years"                                                                                                                
## [267] "Percent Margin of Error!!SEX AND AGE!!Total population!!15 to 19 years"                                                                                                         
## [268] "Estimate!!SEX AND AGE!!Total population!!20 to 24 years"                                                                                                                        
## [269] "Margin of Error!!SEX AND AGE!!Total population!!20 to 24 years"                                                                                                                 
## [270] "Percent Estimate!!SEX AND AGE!!Total population!!20 to 24 years"                                                                                                                
## [271] "Percent Margin of Error!!SEX AND AGE!!Total population!!20 to 24 years"                                                                                                         
## [272] "Estimate!!SEX AND AGE!!Total population!!25 to 34 years"                                                                                                                        
## [273] "Margin of Error!!SEX AND AGE!!Total population!!25 to 34 years"                                                                                                                 
## [274] "Percent Estimate!!SEX AND AGE!!Total population!!25 to 34 years"                                                                                                                
## [275] "Percent Margin of Error!!SEX AND AGE!!Total population!!25 to 34 years"                                                                                                         
## [276] "Estimate!!SEX AND AGE!!Total population!!35 to 44 years"                                                                                                                        
## [277] "Margin of Error!!SEX AND AGE!!Total population!!35 to 44 years"                                                                                                                 
## [278] "Percent Estimate!!SEX AND AGE!!Total population!!35 to 44 years"                                                                                                                
## [279] "Percent Margin of Error!!SEX AND AGE!!Total population!!35 to 44 years"                                                                                                         
## [280] "Estimate!!SEX AND AGE!!Total population!!45 to 54 years"                                                                                                                        
## [281] "Margin of Error!!SEX AND AGE!!Total population!!45 to 54 years"                                                                                                                 
## [282] "Percent Estimate!!SEX AND AGE!!Total population!!45 to 54 years"                                                                                                                
## [283] "Percent Margin of Error!!SEX AND AGE!!Total population!!45 to 54 years"                                                                                                         
## [284] "Estimate!!SEX AND AGE!!Total population!!55 to 59 years"                                                                                                                        
## [285] "Margin of Error!!SEX AND AGE!!Total population!!55 to 59 years"                                                                                                                 
## [286] "Percent Estimate!!SEX AND AGE!!Total population!!55 to 59 years"                                                                                                                
## [287] "Percent Margin of Error!!SEX AND AGE!!Total population!!55 to 59 years"                                                                                                         
## [288] "Estimate!!SEX AND AGE!!Total population!!60 to 64 years"                                                                                                                        
## [289] "Margin of Error!!SEX AND AGE!!Total population!!60 to 64 years"                                                                                                                 
## [290] "Percent Estimate!!SEX AND AGE!!Total population!!60 to 64 years"                                                                                                                
## [291] "Percent Margin of Error!!SEX AND AGE!!Total population!!60 to 64 years"                                                                                                         
## [292] "Estimate!!SEX AND AGE!!Total population!!65 to 74 years"                                                                                                                        
## [293] "Margin of Error!!SEX AND AGE!!Total population!!65 to 74 years"                                                                                                                 
## [294] "Percent Estimate!!SEX AND AGE!!Total population!!65 to 74 years"                                                                                                                
## [295] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 to 74 years"                                                                                                         
## [296] "Estimate!!SEX AND AGE!!Total population!!75 to 84 years"                                                                                                                        
## [297] "Margin of Error!!SEX AND AGE!!Total population!!75 to 84 years"                                                                                                                 
## [298] "Percent Estimate!!SEX AND AGE!!Total population!!75 to 84 years"                                                                                                                
## [299] "Percent Margin of Error!!SEX AND AGE!!Total population!!75 to 84 years"                                                                                                         
## [300] "Estimate!!SEX AND AGE!!Total population!!85 years and over"                                                                                                                     
## [301] "Margin of Error!!SEX AND AGE!!Total population!!85 years and over"                                                                                                              
## [302] "Percent Estimate!!SEX AND AGE!!Total population!!85 years and over"                                                                                                             
## [303] "Percent Margin of Error!!SEX AND AGE!!Total population!!85 years and over"                                                                                                      
## [304] "Estimate!!SEX AND AGE!!Total population!!Median age (years)"                                                                                                                    
## [305] "Margin of Error!!SEX AND AGE!!Total population!!Median age (years)"                                                                                                             
## [306] "Percent Estimate!!SEX AND AGE!!Total population!!Median age (years)"                                                                                                            
## [307] "Percent Margin of Error!!SEX AND AGE!!Total population!!Median age (years)"                                                                                                     
## [308] "Estimate!!SEX AND AGE!!Total population!!Under 18 years"                                                                                                                        
## [309] "Margin of Error!!SEX AND AGE!!Total population!!Under 18 years"                                                                                                                 
## [310] "Percent Estimate!!SEX AND AGE!!Total population!!Under 18 years"                                                                                                                
## [311] "Percent Margin of Error!!SEX AND AGE!!Total population!!Under 18 years"                                                                                                         
## [312] "Estimate!!SEX AND AGE!!Total population!!16 years and over"                                                                                                                     
## [313] "Margin of Error!!SEX AND AGE!!Total population!!16 years and over"                                                                                                              
## [314] "Percent Estimate!!SEX AND AGE!!Total population!!16 years and over"                                                                                                             
## [315] "Percent Margin of Error!!SEX AND AGE!!Total population!!16 years and over"                                                                                                      
## [316] "Estimate!!SEX AND AGE!!Total population!!18 years and over...316"                                                                                                               
## [317] "Margin of Error!!SEX AND AGE!!Total population!!18 years and over...317"                                                                                                        
## [318] "Percent Estimate!!SEX AND AGE!!Total population!!18 years and over...318"                                                                                                       
## [319] "Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over...319"                                                                                                
## [320] "Estimate!!SEX AND AGE!!Total population!!21 years and over"                                                                                                                     
## [321] "Margin of Error!!SEX AND AGE!!Total population!!21 years and over"                                                                                                              
## [322] "Percent Estimate!!SEX AND AGE!!Total population!!21 years and over"                                                                                                             
## [323] "Percent Margin of Error!!SEX AND AGE!!Total population!!21 years and over"                                                                                                      
## [324] "Estimate!!SEX AND AGE!!Total population!!62 years and over"                                                                                                                     
## [325] "Margin of Error!!SEX AND AGE!!Total population!!62 years and over"                                                                                                              
## [326] "Percent Estimate!!SEX AND AGE!!Total population!!62 years and over"                                                                                                             
## [327] "Percent Margin of Error!!SEX AND AGE!!Total population!!62 years and over"                                                                                                      
## [328] "Estimate!!SEX AND AGE!!Total population!!65 years and over...328"                                                                                                               
## [329] "Margin of Error!!SEX AND AGE!!Total population!!65 years and over...329"                                                                                                        
## [330] "Percent Estimate!!SEX AND AGE!!Total population!!65 years and over...330"                                                                                                       
## [331] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over...331"                                                                                                
## [332] "Estimate!!SEX AND AGE!!Total population!!18 years and over...332"                                                                                                               
## [333] "Margin of Error!!SEX AND AGE!!Total population!!18 years and over...333"                                                                                                        
## [334] "Percent Estimate!!SEX AND AGE!!Total population!!18 years and over...334"                                                                                                       
## [335] "Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over...335"                                                                                                
## [336] "Estimate!!SEX AND AGE!!Total population!!18 years and over!!Male"                                                                                                               
## [337] "Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Male"                                                                                                        
## [338] "Percent Estimate!!SEX AND AGE!!Total population!!18 years and over!!Male"                                                                                                       
## [339] "Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Male"                                                                                                
## [340] "Estimate!!SEX AND AGE!!Total population!!18 years and over!!Female"                                                                                                             
## [341] "Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Female"                                                                                                      
## [342] "Percent Estimate!!SEX AND AGE!!Total population!!18 years and over!!Female"                                                                                                     
## [343] "Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Female"                                                                                              
## [344] "Estimate!!SEX AND AGE!!Total population!!18 years and over!!Sex ratio (males per 100 females)"                                                                                  
## [345] "Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Sex ratio (males per 100 females)"                                                                           
## [346] "Percent Estimate!!SEX AND AGE!!Total population!!18 years and over!!Sex ratio (males per 100 females)"                                                                          
## [347] "Percent Margin of Error!!SEX AND AGE!!Total population!!18 years and over!!Sex ratio (males per 100 females)"                                                                   
## [348] "Estimate!!SEX AND AGE!!Total population!!65 years and over...348"                                                                                                               
## [349] "Margin of Error!!SEX AND AGE!!Total population!!65 years and over...349"                                                                                                        
## [350] "Percent Estimate!!SEX AND AGE!!Total population!!65 years and over...350"                                                                                                       
## [351] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over...351"                                                                                                
## [352] "Estimate!!SEX AND AGE!!Total population!!65 years and over!!Male"                                                                                                               
## [353] "Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Male"                                                                                                        
## [354] "Percent Estimate!!SEX AND AGE!!Total population!!65 years and over!!Male"                                                                                                       
## [355] "Percent Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Male"                                                                                                
## [356] "Estimate!!SEX AND AGE!!Total population!!65 years and over!!Female"                                                                                                             
## [357] "Margin of Error!!SEX AND AGE!!Total population!!65 years and over!!Female"                                                                                                      
## [358] "Percent Estimate!!SEX AND AGE!!Total population!!65 years and over!!Female"
acs <- acs %>%
  select(
    id,
    totPop = `Estimate!!SEX AND AGE!!Total population`
  ) %>%
  mutate(tract_full = str_sub(id, -11, -1)) #Simplify name and creates new column for join

tracts_2010 <- tracts_2010 %>%
  mutate(
    cntyFIPS = case_when(
      boro_name == "Bronx" ~ "005",
      boro_name == "Brooklyn" ~ "047",
      boro_name == "Manhattan" ~ "061",
      boro_name == "Queens" ~ "081",
      boro_name == "Staten Island" ~ "085"
    ),
    tract_full = paste0("36", cntyFIPS, sprintf("%06d", as.numeric(ct2010)))
  )#Fix tracts for matching to ACS data

popData <- merge(tracts_2010, acs, by = "tract_full") #Join to ACS

Task 5: Aggregate the ACS Census data to zip code area data

popNYC <- st_transform(popData, st_crs(zip_health)) #Join ACS data to zip codes

zip_final <- st_join(
  zip_health,
  popNYC %>% st_centroid(),
  join = st_contains
) %>%
  group_by(ZIPCODE, Positive, Total, food_store_count, health_count) %>%
  summarise(
    total_population = sum(totPop, na.rm = TRUE)
  ) #Spatial Join and Aggregation all together 
## Warning: st_centroid assumes attributes are constant over geometries
## `summarise()` has regrouped the output.
## ℹ Summaries were computed grouped by ZIPCODE, Positive, Total,
##   food_store_count, and health_count.
## ℹ Output is grouped by ZIPCODE, Positive, Total, and food_store_count.
## ℹ Use `summarise(.groups = "drop_last")` to silence this message.
## ℹ Use `summarise(.by = c(ZIPCODE, Positive, Total, food_store_count,
##   health_count))` for per-operation grouping (`?dplyr::dplyr_by`) instead.
head(zip_final) #Final check that everything is together 
## Simple feature collection with 6 features and 6 fields
## Geometry type: GEOMETRY
## Dimension:     XY
## Bounding box:  xmin: 971132.6 ymin: 188447.3 xmax: 998309.7 ymax: 230942.5
## Projected CRS: NAD83 / New York Long Island (ftUS)
## # A tibble: 6 × 7
## # Groups:   ZIPCODE, Positive, Total, food_store_count [6]
##   ZIPCODE Positive Total food_store_count health_count total_population
##   <chr>      <dbl> <dbl>            <int>        <int>            <dbl>
## 1 00083         NA    NA                1            1                3
## 2 10001        260   571               54            3            19146
## 3 10002        712  1358              199            3            74310
## 4 10003        347   830               94            3            53487
## 5 10004         24    64               13            1             1731
## 6 10005         44   137                9            1             8809
## # ℹ 1 more variable: geom <GEOMETRY [US_survey_foot]>