toc: true toc-location: left code-fold: true code-summary: “Show the code” code-tools: true
In the following R code chunk, load_packages is the code
chunk name. include=FALSE suggests that the code chunk will
run, but the code itself and its outputs will not be included in the
rendered HTML. echo=TRUE in the following code chunk
suggests that the code and results from running the code will be
included in the rendered HTML.
Don’t use a single chunk for the entire assignment. Break it into multiple chunks.
smpCode <- "hello, R markdown and RPubs!"
cat(smpCode)
## hello, R markdown and RPubs!
Quarto markdown is different from R markdown in terms of chunk options. See chunk options at Quarto website.
print("This is the new code chunk options available in Quarto Markdown")
## [1] "This is the new code chunk options available in Quarto Markdown"
#Tasks for the first lab: #Set up a R project for the R-Spatial section. #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.
NYCpostal_sf <- st_read("/Users/veronicawelsh/Desktop/gtech r/Week_07/R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp")
## Reading layer `ZIP_CODE_040114' from data source
## `/Users/veronicawelsh/Desktop/gtech r/Week_07/R-Spatial_I_Lab/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)
#Read and process the NYS health facilities spreadsheet data. Create sf objects from geographic coordinates.
nys_healthfac_data<-read.csv("/Users/veronicawelsh/Desktop/gtech r/Week_07/R-Spatial_I_Lab/NYS_Health_Facility.csv", stringsAsFactors = FALSE)
nys_healthfac_data %>% head()
## Facility.ID Facility.Name Short.Description
## 1 204 Hospice at Lourdes HSPC
## 2 620 Charles T Sitrin Health Care Center Inc NH
## 3 654 Central Park Rehabilitation and Nursing Center NH
## 4 1156 East Side Nursing Home NH
## 5 2589 Wellsville Manor Care Center NH
## 6 3455 Harris Hill Nursing Facility, LLC NH
## Description Facility.Open.Date
## 1 Hospice 06/01/1985
## 2 Residential Health Care Facility - SNF 02/01/1989
## 3 Residential Health Care Facility - SNF 02/01/1989
## 4 Residential Health Care Facility - SNF 08/01/1979
## 5 Residential Health Care Facility - SNF 02/01/1989
## 6 Residential Health Care Facility - SNF 04/08/1992
## Facility.Address.1 Facility.Address.2 Facility.City Facility.State
## 1 4102 Old Vestal Road Vestal New York
## 2 2050 Tilden Avenue New Hartford New York
## 3 116 Martin Luther King East Syracuse New York
## 4 62 Prospect St Warsaw New York
## 5 4192A Bolivar Road Wellsville New York
## 6 2699 Wehrle Drive Williamsville New York
## Facility.Zip.Code Facility.Phone.Number Facility.Fax.Number Facility.Website
## 1 13850 6077985692 NA
## 2 13413 3157973114 NA
## 3 13205 3154751641 NA
## 4 14569 5857868151 NA
## 5 14895 5855934400 NA
## 6 14221 7166323700 NA
## Facility.County.Code Facility.County Regional.Office.ID
## 1 3 Broome 3
## 2 32 Oneida 3
## 3 33 Onondaga 3
## 4 60 Wyoming 1
## 5 2 Allegany 1
## 6 14 Erie 1
## Regional.Office Main.Site.Name Main.Site.Facility.ID
## 1 Central New York Regional Office NA
## 2 Central New York Regional Office NA
## 3 Central New York Regional Office NA
## 4 Western Regional Office - Buffalo NA
## 5 Western Regional Office - Buffalo NA
## 6 Western Regional Office - Buffalo NA
## Operating.Certificate.Number Operator.Name
## 1 0301501F Our Lady of Lourdes Memorial Hospital Inc
## 2 3227304N Charles T Sitrin Health Care Center, Inc
## 3 3301326N CPRNC, LLC
## 4 6027303N East Side Nursing Home Inc
## 5 0228305N Wellsville Manor LLC
## 6 1406301N Harris Hill Nursing Facility, LLC
## Operator.Address.1 Operator.Address.2 Operator.City
## 1 169 Riverside Drive Binghamton
## 2 Box 1000 Tilden Avenue New Hartford
## 3 116 Martin Luther King East Syracuse
## 4 62 Prospect Street Warsaw
## 5 4192a Bolivar Road Wellsville
## 6 560 Delaware Avenue, Suite 400 Buffalo
## Operator.State Operator.Zip.Code Cooperator.Name Cooperator.Address
## 1 New York 13905
## 2 New York 13413
## 3 New York 13205
## 4 New York 14569
## 5 New York 14897
## 6 New York 14202
## Cooperator.Address.2 Cooperator.City Cooperator.State Cooperator.Zip.Code
## 1 New York NA
## 2 New York NA
## 3 New York NA
## 4 New York NA
## 5 New York NA
## 6 New York NA
## Ownership.Type Facility.Latitude Facility.Longitude
## 1 Not for Profit Corporation 42.09710 -75.97524
## 2 Not for Profit Corporation 43.05497 -75.22883
## 3 LLC NA NA
## 4 Business Corporation 42.73898 -78.12867
## 5 LLC 42.12646 -77.96783
## 6 LLC 42.95627 -78.68856
## Facility.Location
## 1 (42.097095, -75.975243)
## 2 (43.05497, -75.228828)
## 3
## 4 (42.738979, -78.12867)
## 5 (42.126461, -77.967834)
## 6 (42.956268, -78.68856)
missing_latlong <- is.na(nys_healthfac_data$Facility.Longitude) | is.na(nys_healthfac_data$Facility.Latitude)
nys_healthfac_data_cleaned <- nys_healthfac_data[!missing_latlong, ]
nys_healthfac_sf <- st_as_sf(nys_healthfac_data_cleaned, coords = c("Facility.Longitude", "Facility.Latitude"))
st_crs(nys_healthfac_sf) <- 4326
mapview(nys_healthfac_sf)