Markdown example with knitr and googleVis

This is a little Markdown example output. The Markdown source file is hosted on GitHub.

Set the googleVis options first to change the behaviour of plot.gvis, so that only the chart component of the HTML file is written into the output file.

op <- options(gvis.plot.tag='chart')

The following plot statements will automatically return the HTML required for the 'knitted' output.

Combo chart

## Add the mean
CC <- gvisComboChart(CityPopularity, xvar='City',
          yvar=c('Mean', 'Popularity'),
                       width=450, height=300,
                       title='City Popularity',
                       series='{0: {type:\"line\"}}'))

Example of gvisComboChart with R code shown above.

Place two charts next to each other

Example of a gvisGeoChart with gvisTable and R code hidden.

Motion Chart

M <- gvisMotionChart(Fruits, 'Fruit', 'Year',
         options=list(width=400, height=350))

Please note that the Motion Chart is only displayed when hosted on a web server, or if placed in a directory which has been added to the trusted sources in the security settings of Macromedia. See the googleVis package vignette for more details.

## Set options back to original options