Purpose

For this assignment, create a series of 5 maps that highlight spatial differences in hospital service coverage for the state of PA. The dataset contains a number of variables about each hospital, many of them are clear and straight forward. You might wish to combine or recode some variables to improve your analysis.

Be sure you map the points with attention to the design principles presented in class.Each map should have an accompanying description that is detailed and clearly written. Make note of any spatial patterns or anomalies of hospital services that you see in the state of PA.

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
library(maptools)
## Warning: package 'maptools' was built under R version 3.4.4
## Loading required package: sp
## Checking rgeos availability: TRUE
library(foreign)
library(ggplot2)
library(ggmap)
library(rgdal)
## rgdal: version: 1.2-8, (SVN revision 663)
##  Geospatial Data Abstraction Library extensions to R successfully loaded
##  Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15
##  Path to GDAL shared files: C:/Users/nd911/OneDrive/Documents/R/win-library/3.4/rgdal/gdal
##  Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
##  Path to PROJ.4 shared files: C:/Users/nd911/OneDrive/Documents/R/win-library/3.4/rgdal/proj
##  Linking to sp version: 1.2-5
data <- read.dbf("C:/Users/nd911/OneDrive/Documents/pennsylv.dbf")
View(data)

Hospitals with Chemotherapy treatment in Pennsylvania and Philadelphia

We created a subset ‘chemo’ of the original dataset ‘data’ to only include the hospitals in Pennsylvania where chemo treatment is provided. Our output shows that the hospitals with chemo treatment facility are widely distributed over Pennsylvania with higher concentration in Philadelhia and Pittsburgh. So we further created a subset of the ‘chemo’ dataset to include hospitals in Philadelphia. We noticed that the hospitals are mostly evenly distributed with a slightly higher concentration in central Philadelhia. Using the quick map plot function, we specified longitude and latitude values, dataset, size and color of the output, map zoom, map source, map extent(how much of the plot should the map take up), color of darken (0 indicates no darkening, 1 indicates a black-out), map type, title of the map, labelled x-axis and y-a-xis.

chemo <- subset(data, chemo=="Y")
chemo_phl <-subset(chemo, city=="Philadelphia")

qmplot(x, y, data = chemo, legend = "none", size = I(2), colour= I('red'), zoom = 7, mapcolor = "color", extent = "panel",darken = 0.1, main = "Chemo Hospitals in PA", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'toner-lite')
## maptype = "toner-lite" is only available with source = "stamen".
## resetting to source = "stamen"...
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.71003&zoom=7&size=640x640&scale=2&maptype=terrain&sensor=false
## Map from URL : http://tile.stamen.com/toner-lite/7/35/46.png
## Map from URL : http://tile.stamen.com/toner-lite/7/36/46.png
## Map from URL : http://tile.stamen.com/toner-lite/7/37/46.png
## Map from URL : http://tile.stamen.com/toner-lite/7/35/47.png
## Map from URL : http://tile.stamen.com/toner-lite/7/36/47.png
## Map from URL : http://tile.stamen.com/toner-lite/7/37/47.png
## Map from URL : http://tile.stamen.com/toner-lite/7/35/48.png
## Map from URL : http://tile.stamen.com/toner-lite/7/36/48.png
## Map from URL : http://tile.stamen.com/toner-lite/7/37/48.png
## Map from URL : http://tile.stamen.com/toner-lite/7/35/49.png
## Map from URL : http://tile.stamen.com/toner-lite/7/36/49.png
## Map from URL : http://tile.stamen.com/toner-lite/7/37/49.png

qmplot(x, y, data = chemo_phl, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Chemo Hospitals in Philadelphia", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'toner-lite', size = I(2), zoom = 11)
## maptype = "toner-lite" is only available with source = "stamen".
## resetting to source = "stamen"...
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.012589,-75.136495&zoom=11&size=640x640&scale=2&maptype=terrain&sensor=false
## Map from URL : http://tile.stamen.com/toner-lite/11/595/773.png
## Map from URL : http://tile.stamen.com/toner-lite/11/596/773.png
## Map from URL : http://tile.stamen.com/toner-lite/11/597/773.png
## Map from URL : http://tile.stamen.com/toner-lite/11/595/774.png
## Map from URL : http://tile.stamen.com/toner-lite/11/596/774.png
## Map from URL : http://tile.stamen.com/toner-lite/11/597/774.png
## Map from URL : http://tile.stamen.com/toner-lite/11/595/775.png
## Map from URL : http://tile.stamen.com/toner-lite/11/596/775.png
## Map from URL : http://tile.stamen.com/toner-lite/11/597/775.png
## Map from URL : http://tile.stamen.com/toner-lite/11/595/776.png
## Map from URL : http://tile.stamen.com/toner-lite/11/596/776.png
## Map from URL : http://tile.stamen.com/toner-lite/11/597/776.png

Hospitals with Ultrasound facility in Pennsylvania

We created a subset ‘ultrasound’ of the original dataset ‘data’ to only include the hospitals in Pennsylvania where ultrasound facility is available. Our output shows that the hospitals with ultrasound facility are widely distributed over Pennsylvania with higher concentration in Philadelhia and Pittsburgh. Using the quick map plot function, we specified longitude and latitude values, dataset, size and color of the output, map zoom, map source, map extent(how much of the plot should the map take up), color of darken (0 indicates no darkening, 1 indicates a black-out), map type, title of the map, labelled x-axis and y-a-xis.

ultrasound <- subset(data, ultrasound=="Y")
qmplot(x, y, data = ultrasound, legend = "none", colour= I('blue'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Ultrasound Hospitals in Pennsylvania", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'roadmap', size = I(1.25), zoom = 7)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.681596&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false

Hospitals with Helipads in Pennsylavania

We created a subset ‘helipad’ of the original dataset ‘data’ to only include the hospitals in Pennsylvania where helipad facility is available. Our output shows that the hospitals with helipad are widely distributed over Pennsylvania with higher concentration in Philadelhia and Pittsburgh. Using the quick map plot function, we specified longitude and latitude values, dataset, size of the output, map zoom, map source, map extent(how much of the plot should the map take up), map type, title of the map, labelled x-axis and y-a-xis.

helipad <- subset(data, helipad=="Y")
qmplot(x, y, data = helipad, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Hospitals with Helipad  across Pennsylvania", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(1.25), zoom = 7)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.681828&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false

Hospitals with Emergency departments in Pennsylavania

Our output shows that hospitals with Emergency dept in Pennsylvania are evenly distributed with higher concentrations in Pittsburgh and Philadephia. We created a subset’emergency’ of main dataset’data’ to only include the data for hospitals where Emergency departments exist.

Using the quick map plot function, we specified longitude and latitude values, dataset, size of the output, map zoom, map source, map extent(how much of the plot should the map take up), map type, title of the map, labelled x-axis and y-a-xis.

emergency = subset(data, emer_dept == "Y")

qmplot(x, y, data = emergency, colour = I('red'), size = I(1.25), zoom = 7, extent = "panel", source = "google", maptype = "hybrid", main = "Hospitals with Emergency dept in Pennsylvania", xlab = "Longitude", ylab = "Latitude")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.681596&zoom=7&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false

Hospitals with Emergency departments in Pittsburgh

Hospitals with Emergency department are distributed all across Pennsylvania without showing any particular trend in any counties. We created a subset emer_pts’ of the ‘emergency’ subset created in the aboe step to focus only on the city of Pittsburgh. Using the quick map plot function, we specified longitude and latitude values, dataset, size of the output, map zoom, map source, map extent(how much of the plot should the map take up), map type, title of the map, labelled x-axis and y-a-xis

emer_pts = subset(emergency, city=="Pittsburgh")

qmplot(x, y, data = emer_pts, colour = I('red'), size = I(2), zoom = 12, darken = 0.1, extent = "panel", source = "google", maptype = "hybrid", main = "Hospitals with Emergency dept. in Pittsburgh", xlab = "Longitude", ylab = "Latitude")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.445396,-79.981289&zoom=12&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
## Warning: Removed 2 rows containing missing values (geom_point).

Conclusion

Our results conclude that even though the population of hospitals in Pennsylvania is evenly distributed, Philadelhia and Pittsburgh have a higher concentration of hospitals with facilities such as emergency dept, ultrasound, chemo treatment and helipad.

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.