Learn R Programming

googleVis (version 0.2.6)

gvisIntensityMap: Google Intensity Map with R

Description

An intensity map highlights regions or countries based on relative values.

The gvisIntensityMap 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.

Usage

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

Arguments

data
a data.frame. The data has to have at least two columns with location name (locationvar) and any number of numeric columns (numvar) to be mapped.
locationvar
column name of data with the geo locations to be analysed. The location has to contain country ISO codes or USA state codes.
numvar
column names of data with the numeric values to be displayed.
options
list of configuration options for Google Intensity Map. The possible components are, taken from http://code.google.com/apis/visualization/documentation/gallery/intensitymap.html#Configuration_Options: [object Object],[object Ob
chartid
character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

  • gvisIntensityMap 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 'IntensityMap'
  • 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 Intensity Map API: http://code.google.com/apis/visualization/documentation/gallery/intensitymap.html

Follow the link for Google's data policy.

See Also

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

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.

df=data.frame(country=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))
Intensity1 <- gvisIntensityMap(df, locationvar="country", numvar=c("val1", "val2"))
plot(Intensity1)

## Set colours for each tab
Intensity2 <- gvisIntensityMap(df,
              options=list(colors="['#4682b4', '#0073CF']"))
plot(Intensity2)

Run the code above in your browser using DataLab