library(foreign)
library(ggplot2)
library(maps)
library(ggmap)
penn <- read.dbf("pennsylv.dbf")
names(penn)
##   [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"
icu<-subset(penn, organ_bank == "Y") 
qmplot(x, y, data = icu, extent = "darken",darken = .5, color = "red", size = 4, main = "Hospitals with Organ Banks in PA", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 8...
## 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

icu<-subset(penn, helipad == "Y") 
qmplot(x, y, data = icu, extent = "darken",darken = .5, color = "red", size = 4, main = "Hospitals with a Helipad in PA", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 8...
## 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

icu<-subset(penn, heart_tran== "Y") 
qmplot(x, y, data = icu, extent = "darken",darken = .5, color = "red", size = 4, main = "Hospitals with Heart TXP centers in PA", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 10...
## 48 tiles needed, this may take a while (try a smaller zoom).
## Map from URL : http://tile.stamen.com/toner-lite/10/283/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/284/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/285/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/286/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/287/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/288/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/289/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/290/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/291/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/292/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/293/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/294/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/295/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/296/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/297/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/298/385.png
## Map from URL : http://tile.stamen.com/toner-lite/10/283/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/284/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/285/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/286/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/287/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/288/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/289/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/290/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/291/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/292/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/293/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/294/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/295/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/296/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/297/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/298/386.png
## Map from URL : http://tile.stamen.com/toner-lite/10/283/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/284/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/285/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/286/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/287/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/288/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/289/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/290/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/291/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/292/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/293/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/294/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/295/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/296/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/297/387.png
## Map from URL : http://tile.stamen.com/toner-lite/10/298/387.png

icu<-subset(penn, pediatric== "Y") 
qmplot(x, y, data = icu, extent = "darken",darken = .5, color = "red", size = 4, main = "Hospitals with pediatric units in PA", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 8...

icu<-subset(penn,pharmacy == "Y") 
qmplot(x, y, data = icu, extent = "darken",darken = .5, color = "red", size = 4, main = "Hospitals with pharmacies in PA", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 8...