Dynamic Graphics with the googleVis Package

Special options

See the vignette of “googleVis” 4 Using googleVis with knitr

define reason
result='asis' HTML code should not be treated as markdown.
print(obj, 'chart') to remove <html> and <body> tags.

### Example Form “Gallery of Examples” in Using R Markdown with RStudio

  1. gvisGeoChart
  2. gvisTable
  3. gvisMerge
  4. gvisMap
  5. gvisComboChart # in gv2.Rmd

Interactive Chart and Map

suppressPackageStartupMessages(library(googleVis))
T <- gvisTable(Exports, options = list(width = 200, height = 280))
G <- gvisGeoChart(Exports, locationvar = "Country", colorvar = "Profit", options = list(width = 360, 
    height = 280, dataMode = "regions"))
TG <- gvisMerge(T, G, horizontal = TRUE, tableOptions = "bgcolor=\"#CCCCCC\" cellspacing=10")
print(TG, "chart")

Hurricane Andrew

## Hurricane Andrew (1992) storm track with Google Maps
AndrewMap <- gvisMap(Andrew, "LatLong", "Tip", options = list(showTip = TRUE, 
    showLine = TRUE, enableScrollWheel = TRUE, mapType = "hybrid", useMapTypeControl = TRUE))
print(AndrewMap, "chart")

Dynamic Table

## Table with embedded links
PopTable <- gvisTable(Population, options = list(width = 600, height = 300, 
    page = "enable"))
print(PopTable, "chart")