Using the spatial visualization techniques, we explore this data set on Pennsylvania hospitals (http://www.arcgis.com/home/item.html?id=eccee5dfe01e4c4283c9be0cfc596882). We created a series of 5 maps that highlight spatial differences in hospital service coverage for the state of PA.
To import the data I use the foreign
package.
library(foreign)
library(ggmap)
## Warning: package 'ggmap' was built under R version 3.6.1
## Loading required package: ggplot2
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(ggplot2)
dat <- read.dbf("pennsylv.dbf") # change this to connect to your version
The dataset contains a number of variables about each hospital, many of them are clear and straight forward.
names(dat)
## [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"
Locations of All Hospital in PA State
qmplot(x, y, data = dat, size = I(3),alpha = I(0.8),extent = "device", geom = "point",main = "Locations of hospitals in Pennsylvania", xlab = "Longitude", ylab = "Latitude",source = "google",maptype = "roadmap",zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.942826,-77.681596&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx-WUKoKBD9BZHFSjo
Hospital in PA with Cardiac Surgery Facilities
heart_transplant = subset(dat, heart_tran == "Y")
qmplot(x, y, data = heart_transplant, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel", main = "Hospitals in PA with Heart Transplant Surgery Unit", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'roadmap', zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.20258,-77.577704&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx-WUKoKBD9BZHFSjo
Hospitals with Air Ambulance Services
amb<-subset(dat, air_amb == "Y")
qmplot(x, y, data = amb, size = I(3),alpha = I(0.8),,extent = "device", geom = "point",main = "Hospitals offering Air Ambulance Services in PA", xlab = "Longitude", ylab = "Latitude",source = "google",maptype = "roadmap",zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=41.040851,-77.606184&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx-WUKoKBD9BZHFSjo
## Warning: Ignoring unknown parameters: NA
Hospitals with Chemotherapy Services in Entire PA
chemotherapy = subset(dat, chemo == "Y")
qmplot(x, y, data = chemotherapy, size = I(3),alpha = I(0.8),color="red",extent = "device", geom = "point",main = "Hospitals with Chemotherapy Services in PA", xlab = "Longitude", ylab = "Latitude",source = "google",maptype = "roadmap",zoom = 7)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.942648,-77.71003&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx-WUKoKBD9BZHFSjo
Hospitals in Pittsburg, PA that take care of pets
pet_hos<-subset(dat, pet == "Y")
pet_hos = subset(pet_hos, city == "Pittsburgh")
qmplot(x,y, data = pet_hos, colour = I('red'), size = I(4), zoom = 11, extent = "panel", source = "google", maptype = "toner", main = "Hospitals in Pittsburg, PA that take care of pets", xlab = "Longitude", ylab = "Latitude")
## maptype = "toner" is only available with source = "stamen".
## resetting to source = "stamen"...
## Source : https://maps.googleapis.com/maps/api/staticmap?center=40.504746,-79.980108&zoom=11&size=640x640&scale=2&maptype=terrain&key=xxx-WUKoKBD9BZHFSjo
## Source : http://tile.stamen.com/toner/11/567/770.png
## Source : http://tile.stamen.com/toner/11/568/770.png
## Source : http://tile.stamen.com/toner/11/569/770.png
## Source : http://tile.stamen.com/toner/11/570/770.png
## Source : http://tile.stamen.com/toner/11/567/771.png
## Source : http://tile.stamen.com/toner/11/568/771.png
## Source : http://tile.stamen.com/toner/11/569/771.png
## Source : http://tile.stamen.com/toner/11/570/771.png
## Source : http://tile.stamen.com/toner/11/567/772.png
## Source : http://tile.stamen.com/toner/11/568/772.png
## Source : http://tile.stamen.com/toner/11/569/772.png
## Source : http://tile.stamen.com/toner/11/570/772.png