Plotly with R Markdown

Plotly for R is an interactive, browser-based charting library built on the open source JavaScript graphing library, plotly.js. It works entirely locally, through the HTML widgets framework. Plotly graphs are interactive. You can Click-drag to zoom, shift-click to pan, double-click to autoscale all the graphs.

By default, plotly for R runs locally in your web browser or R Studio’s viewer. You can publish your graphs to the web by creating a plotly account.

To embed plotly plots in R Markdown, simply embed the plotly code into markdown file.

Example:

## Plotly with R Markdown

```{r, plotly=TRUE, echo=FALSE, message=FALSE}
library(ggplot2)
library(plotly) 
p <- plot_ly(iris, x = Petal.Length, y = Petal.Width, color = Species, mode = "markers")
p
```

Sample Output:
plotly

GoogleVis with R Markdown

GoogleVis is a R package from CRAN that allows R interface to Google Charts API. It allows users to create interactive charts based on data frames. Charts are displayed locally via the R HTTP help server.

More examples of all GoogleVis charts from here.

Below is a simple example of displaying GPS latitude and Longitude using R Markdown

Example:

## Googlevis with R Markdown

```{r, results='asis', message=FALSE, echo=FALSE}
library(googleVis)
df &lt;- data.frame(
loc=c(&quot;3.155762:101.716529&quot;,
&quot;3.155923:101.712023&quot;), 
tip=c(&quot;Suria KLCC&quot;,
&quot;Mandarin Oriental&quot;))

M2&lt;-gvisMap(df, &quot;loc&quot;, &quot;tip&quot;, 
options=list(
showTip=TRUE, mapType=&quot;normal&quot;,
enableScrollWheel=TRUE))
print(M2, &quot;chart&quot;)

Output:

googlevis