Learn R Programming

googleVis (version 0.2.6)

gvisGeoChart: Google Geo Chart with R

Description

The gvisGeoChart function reads a data.frame and creates text output referring to the Google Visualisation API which can be included into a web page, or as a stand-alone page.

A geo chart is an SVG-based map of a country, continent, or region map, with colours and values assigned to specific regions. Values are displayed as a color scale, and you can specify optional hovertext for regions. Note that the map is not scrollable or draggable.

Usage

gvisGeoChart(data, locationvar = "", numvar = "", options = list(), chartid)

Arguments

data
a data.frame. The data has to have at least two columns with location name (locationvar), value to be mapped to location (numvar).
locationvar
column name of data with the country name, or an uppercase ISO-3166 code.
numvar
column name of data with the numeric value displayed when the user hovers over this region.
options
list of configuration options for Google Geo Chart. The possible components are, taken from http://code.google.com/apis/visualization/documentation/gallery/geochart.html#Configuration_Options: [object Object],[object Object],[o
chartid
character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

  • gvisGeoChart returns list of class "gvis" and "list". An object of class "gvis" is a list containing at least the following components:
  • typeGoogle visualisation type, here 'GeoChart'
  • chartidcharacter id of the chart object. Unique chart ids are required to place several charts on the same page.
  • htmla list with the building blocks for a page [object Object],[object Object],[object Object],[object Object]

References

Google Geo Map API: http://code.google.com/apis/visualization/documentation/gallery/geochart.html

Follow the link for Google's data policy.

See Also

See also print.gvis, plot.gvis for printing and plotting methods, gvisGeoMap and gvisIntensityMap for an alternative to gvisGeoChart.

Examples

Run this code
## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the visualisation.


G1 <- gvisGeoChart(Exports, locationvar='Country', numvar='Profit') 

plot(G1)

## Plot only Europe
G2 <- gvisGeoChart(Exports, "Country", "Profit",
                   options=list(region="150"))

plot(G2)

Run the code above in your browser using DataLab