Learning Shiny by Hernán G. Resnizky

Learning Shiny by Hernán G. Resnizky

Author:Hernán G. Resnizky [Resnizky, Hernán G.]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2015-10-16T04:00:00+00:00


Geolocalized visualizations

Although there are other possibilities to display geolocalized visualizations, using googleVis is definitely the best one as Google charts is perfectly integrated to Google Maps to provide, in the end, very simple ways to display visualizations with maps and georeferenced data.

There are several different possibilities to plot geolocalized data in R, but they can be divided in two big groups: the ones that use latlong values, and the ones that refer to a geographical space by name (for example, a country name). Most of the functions that create visualizations based on geolocalized data accept both the alternatives as locationvar. Two examples using each of these are given in the following.

In the first one, an artificial data frame with approximate latlong values inside the USA is plotted. Here, region is set to US inside the options argument. The default for this argument is world (that is, display of the whole world):

library(googleVis) #Artificial Dataset generation latitudes <- runif(10,27,49) longitudes <- runif(10,-125,-72) values <- runif(10,0,100) us.dataset <- data.frame(lat=latitudes,long=longitudes,val=values) #Generate a latlong variable as expected in 'locationvar' us.dataset$latlong <- paste(us.dataset$lat,us.dataset$long,sep=":") #Map HTML creation us.map <- gvisGeoChart(us.dataset, locationvar="latlong",sizevar="val", options = list(region="US")) #Plotting plot(us.map)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.