Guest post by Krishna Prasad
As a business analyst using R, one has often stumbled across situations for visually representing the data on a map. Here are some common scenarios:
· Represent the most densely populated cities on a Map
· Showing the cheapest places to live in
· Where can one buy a home with the cheapest home Insurance
These common spatial representation problems can now be solved using the GGMap Integration with R. GGMap is a spatial visualization package for R to show visual data & models on top of Google Map, Open Street Maps or Cloud Maps.
In the below case study, we are going to use Home Insurance Rates Data & use GGMap with R to show home insurance prices for the most populated cities in the US. For example, Chicagos Home Insurance rates are $860 and will be represented in a smaller circle than Houston whose home insurance rates are $960.
Here is the sample data fields for us to improve into our data package:
· Home Insurance Location
· Home Insurance Rates
All these above data fields along with the values can be saved in a CSV file called Average_Home_Insurance.csv. This is the file that can be used to import into our GGMap package to visually represent the data.
Here are the extremely simple steps to import, install & show the data on the map.
#Reading the Home Insurance Data from File
>map<- get_map(location = 'US', zoom = 4)
> TC <-ggmap(map)+geom_point(data=m
apdata,alpha = .7, aes(x=longitude, y=latitude,size =Home.Insurance),color='red')+ ggtitle("Average Home Insurance By City($)")
As the above map screenshot shows, each of the circles are represented with various sizes in the map. In your local package, one can also zoom in at various levels to see close by locations & their home insurance rates. For e.g. in the above map, one can zoom into Texas to see the home insurance rates for Dallas, Houston & Austin.
The above case study was done using Google Maps, but one can also use OpenStreetMaps if you wanted more customization on the markers and definitions.
This case study is by vHomeInsurance (www.vhomeinsurance.com) a home insurance rates & quotes data analysis service