library(foreign)
library(readxl)
## Warning: package 'readxl' was built under R version 3.4.4
datapenn <- read_excel("F:/HU/ANLY 512/Problem Set 5/pennsylv/pennsylv.dbf.xlsx")
names(datapenn)
## [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"
library(ggmap)
## Warning: package 'ggmap' was built under R version 3.4.4
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.4
acc_trauma <- subset(datapenn, acc_trauma=="Y")
qmplot(x, y, data = acc_trauma, legend = "none", colour= I('blue'), mapcolor = "color", extent = "panel",darken = 0.1, main = "ACC Trauma Hospitals in PA", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(3), zoom = 6)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.995052,-77.505472&zoom=6&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
We observe that most of the ACC Trauma Hospitals are concentrate around Philadelphia.
surgical <- subset(datapenn, surgical=="Y")
qmplot(x, y, data = surgical, legend = "none", colour= I('blue'), mapcolor = "color", extent = "panel",darken = 0.1, main = "Surgical Hospitals in PA", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(2), zoom = 7)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.995052,-77.729609&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
We observe that surgical hosiptals are spread out across Pennsylvania with a more important concentration in the East. The density is more important around bigger cities like Philadelphia and Pittsburgh.
chemo <- subset(datapenn, chemo=="Y")
qmplot(x, y, data = chemo, main = "Hospitals with Chemotherapy in PA",color= I('green'),maptype = "toner-lite", source = 'stamen', 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
## 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
We observe a strong concentration of hospitals with chemotherapy around Phildelphia.
qmplot(x, y, data = datapenn, size = icu_beds, mdaptype = "toner-lite", color = I("blue")
)
## Using zoom = 8...
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
## Warning: Ignoring unknown parameters: mdaptype
## Warning: Removed 208 rows containing missing values (geom_point).
The most hopsitals with more than 100 ICU beds are in Philadelphia and Pittsburgh. The rest of hospitals across PA have less than 100 ICU beds.
acc_traumaCounty <- subset(acc_trauma, county=="Philadelphia")
qmplot(x, y, data = acc_traumaCounty, legend = "none", colour= I('blue'), mapcolor = "color", extent = "panel",darken = 0.1, main = "ACC Trauma Hospitals in Philadelphia", xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'roadmap', zoom = 12)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.009619,-75.087825&zoom=12&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false