Using the googleVis package, dynamic tables, maps, and motion charts can be created to allow the reader to interact with the content. Note that gvis objects, by default, contain <html>
and <body>
tags which should be removed since Knit HTML does this already. Passing 'chart'
to the print function accomplishes this. Also you will need to define results='asis'
in your chunk options to ensure the HTML code is not treated as markdown.
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 (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")
## Table with embedded links
PopTable <- gvisTable(Population, options = list(width = 600, height = 300,
page = "enable"))
print(PopTable, "chart")
Return to Using Markdown with RStudio