library(foreign)
data <- read.dbf("C:/Users/mishrk4/Downloads/hospitals/pennsylv.dbf")
library(ggmap)
## Warning: package 'ggmap' was built under R version 3.4.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.3
The below map represents the distribution of Pediatric hospitals in Pennsylvania.
pediatric <- subset(data, pediatric=="Y")
qmplot(x, y, data = pediatric, legend = "none", colour= I('red'), mapcolor = "color", extent = "panel",darken = 0.1, main, xlab = "Longitude", ylab = "Latitude", source = 'google', maptype = 'terrain', size = I(1), zoom = 7)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.860195,-77.45448&zoom=7&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
## Warning: Ignoring unknown parameters: NA
The below map represents the distribution of hospitals in Philadelphia.
Philadelphia<-subset(data, city == "Philadelphia")
qmplot(x, y, data = Philadelphia, color = "blue", size = 3, darken = .3, extent = "panel", main = "Hospitals in Philadelphia", xlab = "Longitude", ylab = "Latitude")
## Using zoom = 12...
## Map from URL : http://tile.stamen.com/toner-lite/12/1191/1549.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1192/1549.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1193/1549.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1194/1549.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1195/1549.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1191/1550.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1192/1550.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1193/1550.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1194/1550.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1195/1550.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1191/1551.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1192/1551.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1193/1551.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1194/1551.png
## Map from URL : http://tile.stamen.com/toner-lite/12/1195/1551.png
The below map represents the density distribution of hospitals in PA with Neurology Services
satellite = get_map(location="pennsylvania", zoom=8,maptype ="satellite")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=pennsylvania&zoom=8&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=pennsylvania&sensor=false
ggmap(satellite) +
stat_density2d(aes(x,y, colour = neurology), data = data, bins = 5, main = "Hospitals in PA with Neurology Services")
## Warning: Ignoring unknown parameters: main
## Warning: Removed 159 rows containing non-finite values (stat_density2d).
The below map represents the distribution of hospitals with MRI Services
ggmap(get_map(location="Philadelphia", zoom=11, maptype="satellite"))+geom_point(aes(x, y, colour = mri), data = data, main = "Hospitals with MRI Location")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Philadelphia&zoom=11&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Philadelphia&sensor=false
## Warning: Ignoring unknown parameters: main
## Warning: Removed 224 rows containing missing values (geom_point).
The below map represents the distribution of hospitals in Pittsburgh with Optometry Services
opt = subset(data, optometry == "Y")
optE = subset(opt, city == "Pittsburgh")
qmplot(x,y, data = optE, colour = I('red'), size = I(2), zoom = 8, extent = "panel", source = "google", maptype = "hybrid", main = "Hospitals in Pittsburgh with Optometry", xlab = "Longitude", ylab = "Latitude")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=40.437147,-79.934733&zoom=8&size=640x640&scale=2&maptype=hybrid&language=en-EN&sensor=false
```