gvisIntensityMap: Google Intensity Map with R

Description Usage Arguments Value Note Author(s) References See Also Examples

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

1
2
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.

gvis.editor

a character label for an on-page button which opens an in-page dialog box that enables users to edit, change and customise the chart. By default no value is given and therefore no button is displayed.

Further possible components are, taken from https://google-developers.appspot.com/chart/interactive/docs/gallery/intensitymap.html#Configuration_Options:

colors

a JSON array of strings. The colors to use for each tab. An array of strings. Each element is a string in the format #rrggbb. For example '#00cc00'.

height

a number. Default 220. Height of the map in pixels. The maximum height of the visualization is 220. Note that this height assumes a one-row tab. If your tab text is long, it will wrap the tab to multiple lines, and the extra lines will exceed the specified height.

region

a string. Default 'world'. The required region. Possible values are: 'world', 'africa', 'asia', 'europe', 'middle_east', 'south_america', and 'usa'.

showOneTab

boolean. Default FALSE. The intensity map can display one or more numeric columns. Each column is displayed as a separate map, and tabs on top enable selection of which map to show. When the data table contains only one numeric column, the tabs are not displayed. To display tabs even for a single numeric column, set this option to TRUE.

width

a number. Default 440. Width of the map in pixels. Note: The maximum width of the visualization is 440.

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:

type

Google visualisation type, here 'IntensityMap'

chartid

character id of the chart object. Unique chart ids are required to place several charts on the same page.

html

a list with the building blocks for a page

header

a character string of a html page header: <html>...<body>,

chart

a named character vector of the chart's building blocks:

jsHeader

Opening <script> tag and reference to Google's JavaScript library.

jsData

JavaScript function defining the input data as a JSON object.

jsDrawChart

JavaScript function combing the data with the visualisation API and user options.

jsDisplayChart

JavaScript function calling the handler to display the chart.

jsFooter

End tag </script>.

jsChart

Call of the jsDisplayChart function.

divChart

<div> container to embed the chart into the page.

caption

character string of a standard caption, including data name and chart id.

footer

character string of a html page footer: </body>...</html>, including the used R and googleVis version and link to Google's Terms of Use.

Note

Map images are generated using the Google Charts API (http://code.google.com/apis/chart/image/docs/gallery/map_charts.html). Please refer to the Chart API logging policy (http://code.google.com/apis/chart/interactive/faq.html#logging).

Author(s)

Markus Gesmann markus.gesmann@gmail.com,

Diego de Castillo decastillo@gmail.com

References

Google Intensity Map API: https://google-developers.appspot.com/chart/interactive/docs/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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

jburos/GoogleVis documentation built on May 18, 2019, 9:19 p.m.