Development package for users R. The spGoogle package provides a interface between R and GoogleMaps for data visualization in both directions. Import GoogleMaps background to R plots and export R data information to GoogleMaps. Currently, on Windows the spGoogle can only export to the browser Google Chrome while on Linux both Google Chrome and Firefox are accepted.
You can install spGoogle
from github using the devtools
package
install.packages("devtools") devtools::install_github("lgsilvaesilva/spGoogle")
A basic example to show how to use the spGoogle package.
require(spGoogle) data(rio) spRplot(rio) #plot in R spGplot(rio) #plot in Google Maps ou Google Earth spGplot(rio, var = "Dengue")
Adding some information in description balloon. After run commands below, click on polygon to see the output.
library(RColorBrewer) require(spGoogle) data(rio) brks <- hist(rio$Dengue, plot = FALSE)$breaks n_cuts <- length(brks) pallete <- brewer.pal(n_cuts-1, 'Blues') names(rio@data) spGplot(rio, var = "Dengue", cuts = brks, col.pallete = list(col = pallete, alpha = 0.8), description = list(title = 'Name', type = 'table', var = c('Income','Urban')), maptype = 'roadmap') spGplot(rio, var = "Dengue", cuts = brks, col.pallete = list(col = pallete, alpha = 0.8), description = list(title = 'Name', type = 'bar', var = c('Income','Urban')), maptype = 'roadmap') spGplot(rio, var = "Dengue", cuts = brks, col.pallete = list(col = pallete, alpha = 0.8), description = list(title = 'Name', type = 'pie', var = c('Income','Urban')), maptype = 'roadmap')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.