Learn R Programming

googleVis (version 0.2.7)

gvisScatterChart: Google Scatter Chart with R

Description

The gvisScatterChart 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. The actual chart is rendered by the web browser using SVG or VML.

Usage

gvisScatterChart(data, options = list(), chartid)

Arguments

data
a data.frame to be displayed as a scatter chart. Two or more columns are required, all must be numeric. The values in the first column are used for the X-axis. The values in following columns
options
list of configuration options for Google Scatter Chart. The possible components are, taken from http://code.google.com/apis/visualization/documentation/gallery/scatterchart.html#Configuration_Options: [object Object],[object Object]
chartid
character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

  • gvisScatterChart 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 'ScatterChart'
  • 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]

Warning

Google Visualisation API: You cannot load both scatterchart and corechart packages at the same time on the same page.

References

Google Scatter Chart API: http://code.google.com/apis/chart/interactive/docs/gallery/scatterchart.html

Follow the link for Google's data policy.

See Also

See also print.gvis, plot.gvis for printing and plotting methods

Examples

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


## Scatter chart
Scatter1 <- gvisScatterChart(women)
plot(Scatter1)

## Using optional arguments
Scatter2 <- gvisScatterChart(women, options=list(legend="none",
                 lineWidth=2, pointSize=0,
                 title="Women", vAxis="{title:'weight (lbs)'}",
                 hAxis="{title:'height (in)'}", width=300, height=300))
                 
plot(Scatter2)


df=data.frame(x=sin(1:100/3), 
              Circle=cos(1:100/3), 
 	      Ellipse=cos(1:100/3)*0.5)

## Plot several variables as smooth curves
Scatter3 <- gvisScatterChart(df, 
	    		options=list(curveType='function', 
				     pointSize=0, 
				     lineWidth=2))
plot(Scatter3)

Run the code above in your browser using DataLab