Using spatial visualization techniques available in R, explore the attached data set on Pennsylvania hospitals,

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. Note: the variables “x” and “Y” are the longitude and latitude data.

For this assignment, create 5 maps. 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. Upload these maps as a document to rpubs.com and submit that link the Moodle assignment.

library(foreign)
library(ggplot2)
library(ggmap)
PA_Hospitals <- read.dbf("Data/pennsylv.dbf")

colnames(PA_Hospitals)
##   [1] "acc_trauma" "air_amb"    "als"        "arc_street" "arc_zone"  
##   [6] "bas_ls"     "bassinets"  "bb_id"      "bc_beds"    "bc_sus_bed"
##  [11] "beds_sus"   "birthing_r" "bone_marro" "burn_car"   "burn_care" 
##  [16] "card_beds"  "card_surge" "card_sus_b" "cardiac"    "cardiac_ca"
##  [21] "cardio_reh" "chemo"      "city"       "clin_lab"   "clin_psych"
##  [26] "county"     "countyname" "ct_scan"    "cty_key"    "cystoscopi"
##  [31] "deliv_rms"  "dental"     "detox_alc_" "diag_radio" "diag_xray" 
##  [36] "doh_hosp"   "doh_phone"  "emer_dept"  "endoscopie" "fac_id"    
##  [41] "facility"   "flu_old"    "fred_con_1" "fred_conta" "fred_email"
##  [46] "fred_fax"   "fred_hosp"  "fred_pager" "fred_phone" "gamma_knif"
##  [51] "gen_outpat" "gene_counc" "heart_tran" "helipad"    "hemodial_c"
##  [56] "hemodial_m" "hosp_id"    "hospice"    "hyper_cham" "icu"       
##  [61] "icu_beds"   "icu_sus_be" "inpat_flu_" "inpat_pneu" "kidney_tra"
##  [66] "labor_rms"  "lic_beds"   "lic_dent"   "lic_dos"    "lic_mds"   
##  [71] "lic_pod"    "linear_acc" "lithotrips" "liver_tran" "loc_method"
##  [76] "ltc"        "mcd"        "mcd_key"    "mcd_name"   "medical"   
##  [81] "mob_ccu"    "mob_icu"    "mri"        "ms1"        "neo2_beds" 
##  [86] "neo2_sus_b" "neo3_beds"  "neo3_sus_b" "neuro_surg" "neurology" 
##  [91] "obs_gyn"    "occ_ther"   "optometry"  "organ_bank" "ped_trauma"
##  [96] "pediatric"  "pet"        "pharmacy"   "phys_med"   "phys_ther" 
## [101] "podiatry"   "providerid" "psych"      "psych_inpa" "reg_trauma"
## [106] "resp_ther"  "so_flu_65u" "social_wor" "speech_pat" "street"    
## [111] "surgical"   "surgical_s" "thera_radi" "typ_org"    "typ_serv"  
## [116] "ultrasound" "x"          "y"          "zip"

The file contains information of 275 hospitals located throughout the State of Pennsylvania. Each record shows information in 119 categories (variables) of each hospital.

As we are looking to explore the spatial differences in hospital service coverage, we will create 5 maps showing hospitals with the selected variables of our interest and provide analysis.

Map 1: Hospital locations in Pennsylvania

Map1 <- qmplot(x, y, data = PA_Hospitals, 
               zoom = 8, darken = 0.1, 
               main = "Hospital Locations in PA")
## Map from URL : http://tile.stamen.com/toner-lite/8/70/94.png
## Map from URL : http://tile.stamen.com/toner-lite/8/71/94.png
## Map from URL : http://tile.stamen.com/toner-lite/8/72/94.png
## Map from URL : http://tile.stamen.com/toner-lite/8/73/94.png
## Map from URL : http://tile.stamen.com/toner-lite/8/74/94.png
## Map from URL : http://tile.stamen.com/toner-lite/8/70/95.png
## Map from URL : http://tile.stamen.com/toner-lite/8/71/95.png
## Map from URL : http://tile.stamen.com/toner-lite/8/72/95.png
## Map from URL : http://tile.stamen.com/toner-lite/8/73/95.png
## Map from URL : http://tile.stamen.com/toner-lite/8/74/95.png
## Map from URL : http://tile.stamen.com/toner-lite/8/70/96.png
## Map from URL : http://tile.stamen.com/toner-lite/8/71/96.png
## Map from URL : http://tile.stamen.com/toner-lite/8/72/96.png
## Map from URL : http://tile.stamen.com/toner-lite/8/73/96.png
## Map from URL : http://tile.stamen.com/toner-lite/8/74/96.png
## Map from URL : http://tile.stamen.com/toner-lite/8/70/97.png
## Map from URL : http://tile.stamen.com/toner-lite/8/71/97.png
## Map from URL : http://tile.stamen.com/toner-lite/8/72/97.png
## Map from URL : http://tile.stamen.com/toner-lite/8/73/97.png
## Map from URL : http://tile.stamen.com/toner-lite/8/74/97.png
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
Map1

This map shows how the hospital locations are spread out across Pennsylvania. As we could see from the map, hospital locations are more clustered around big cities, such as Philadelphia and Pittsburgh, where we could expect larger population than other cities. Therefore, the pattern of hospital locations seems to correspond with the population locations.


Map 2: Comparison of Hospitals with dental service between Philadelphia and Harrisburg

Philly <- subset(PA_Hospitals, PA_Hospitals$city=="Philadelphia")

Philly_Dental <- subset(Philly, PA_Hospitals$dental=="Y")


HRB <- subset(PA_Hospitals, PA_Hospitals$city=="Harrisburg")

HRB_Dental <- subset(HRB, PA_Hospitals$dental=="Y")


Map2.1 <- qmplot(x, y, data = Philly_Dental, 
               color = I('red'), mapcolor = "color",  
               main = "Hospitals in Philadelphia with Dental Service", 
               xlab = "Longitude", ylab = "Latitude", 
               source = 'google', maptype = 'roadmap', zoom = 11)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.002983,-75.168603&zoom=11&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
Map2.2 <- qmplot(x, y, data = HRB_Dental, 
               color = I('blue'), mapcolor = "color",  
               main = "Hospitals in Harrisburg with Dental Service", 
               xlab = "Longitude", ylab = "Latitude", 
               source = 'google', maptype = 'roadmap', zoom = 11)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.257679,-76.880659&zoom=11&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
Map2.1
## Warning: Removed 23 rows containing missing values (geom_point).

Map2.2
## Warning: Removed 26 rows containing missing values (geom_point).

The red dot shown on Philadelphia area map and blue dot shown on Harrisburg area map represent the number of hospitals providing dental care services in the two respective areas. While Harriburg is the capital city of Pennsylvania, there is only one hospital with dental service available. On the other hand, Philadelphia has four hospitals with dental service coverage. The higher number of dental service locations in Philadelphia could correspond to its higher population which would ultimately create higher demand for dental care as it is considered part of basic human hygiene.


Map 3: Hospitals with Organ Banks in PA

OrganBank <- subset(PA_Hospitals, PA_Hospitals$organ_bank == "Y")

Map3 <- qmplot(x, y, data = OrganBank, mapcolor = "color",
               main = "Hospitals in PA with Organ Banks",
               xlab = "Longtitude", ylab = "Latitude",
               source = 'google', maptype = 'terrain', zoom = 7)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.888653,-77.823091&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
Map3

As we could see from the map, black dots represent the hospitals with existence of organ banks at the same locations. Organ banks facilitate long-term storage of tissues destined for transplantation and are usually shared by multiple hospitals. With their specialty nature, we could see that organ banks are scattered more around big cities like Philadelphia or Pittsburg where there are many people living so that the stored tissues/organs could be best accessed and utilized by many hospitals located in the nearby areas.


Map 4: Hospitals in Philadelphia with Intensive Care Unit

Map4 <- ggmap(get_map(location = "Philadelphia", maptype = "toner", zoom = 10)) +
        geom_point(data = PA_Hospitals,
                   aes(x, y, colour = PA_Hospitals$icu, size = PA_Hospitals$icu_beds)) +
        labs(title = "Hospitals in Philadelphia with ICU Coverage")
## maptype = "toner" is only available with source = "stamen".
## resetting to source = "stamen"...
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Philadelphia&zoom=10&size=640x640&scale=2&maptype=terrain&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Philadelphia&sensor=false
## Map from URL : http://tile.stamen.com/toner/10/296/386.png
## Map from URL : http://tile.stamen.com/toner/10/297/386.png
## Map from URL : http://tile.stamen.com/toner/10/298/386.png
## Map from URL : http://tile.stamen.com/toner/10/299/386.png
## Map from URL : http://tile.stamen.com/toner/10/296/387.png
## Map from URL : http://tile.stamen.com/toner/10/297/387.png
## Map from URL : http://tile.stamen.com/toner/10/298/387.png
## Map from URL : http://tile.stamen.com/toner/10/299/387.png
## Map from URL : http://tile.stamen.com/toner/10/296/388.png
## Map from URL : http://tile.stamen.com/toner/10/297/388.png
## Map from URL : http://tile.stamen.com/toner/10/298/388.png
## Map from URL : http://tile.stamen.com/toner/10/299/388.png
## Map from URL : http://tile.stamen.com/toner/10/296/389.png
## Map from URL : http://tile.stamen.com/toner/10/297/389.png
## Map from URL : http://tile.stamen.com/toner/10/298/389.png
## Map from URL : http://tile.stamen.com/toner/10/299/389.png
Map4
## Warning: Removed 254 rows containing missing values (geom_point).

From this map, we could see the all the hospitals with ICU in City of Philadelphia. It seems like most (if not all) of the hospitals in this area are equipped with ICU capability as the dots, used to represent the hospital locations, show mostly “blue” color. We do not notice any red dots on the map. The size of the dot represents the number of ICU beds available at each hospital. The larger the dot size, the more ICU beds capacity at that hospital. Downtown Philadelphia seems to be the area where we could find the hospitals with capacity to support large number of ICU beds.


Map 5: Hospitals in Philadelphia with Optometry Service

Map5 <- ggmap(get_map(location = "Philalphia", maptype = "satellite", zoom = 6)) +
        geom_point(data = PA_Hospitals,
                   aes(x, y, colour = PA_Hospitals$optometry )) +
        labs(title = "Hospitals in Philadelphia with Optometry Service")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Philalphia&zoom=6&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Philalphia&sensor=false
Map5

In this map, we are looking at the hospitals located in Philadelphia area that offer optometry service. As we could see, even though there are many hospitals in this city, not all of them have optometry service for their patients. In fact, we could see that hospitals with no optometry, represented by red dots, seem to outnumber those with the optometry service, represented by blue dots. Since optometry is considered special clinic that requires specialists and doctors in operations, it is understandable why optometry is not offered by most hospitals. Also, as it does not fall under the general treatment, it is not the basic popular reasons why people are visting the hospitals.


`