I'm trying to produce a google motion chart in R slidify. I looked up a lot of examples online and it seems some people have successfully embedded google motion chart in an R slidify slide. Then when I tried my own using similar code, it gives me blank result. I also use the same method to produce a google pie chart and it works well (a pie chart shows in the plotting area)
Here is my simplified code below (Here I am using the Fruits dataset just like all other demo) :
---
title: "Title"
author: "Me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
ioslides_presentation:
incremental: yes
transition: default
widescreen: yes
slidy_presentation:
incremental: yes
job: Job Title
license: by-nc-sa
mode: selfcontained
hitheme: tomorrow
highlighter : highlight.js
subtitle: Subtitle
framework: io2012
widgets: []
---
## GoogleVis Motion chart example
```{r motionchartcode1, results='asis', warning=FALSE, comment=NA}
library(googleVis)
options(gvis.plot.tag='chart')
M <- gvisMotionChart(Fruits, 'Fruit', 'Year',
options=list(width=400, height=350))
#plot(M)
print(M, tag = 'chart')
```
---
## GoogleVis Pie chart example
```{r motionchartcode, results='asis'}
library(googleVis)
options(gvis.plot.tag='chart')
Pie <- gvisPieChart(CityPopularity,
options=list(width=400, height=200))
print(Pie, tag = 'chart')
```
Then I used slidify("demo.Rmd") to compile it to a html file. The first slide gives no plots but a blank plotting area.
I'm not sure which part is effecting this outcome: the setup in --- part, the options in r markdown chunk or my browser environment?
Hope someone can give me ideas.
The plot command in R uses the internal R http help server to overcome this limitation.
Here's how I overcame it:
Also you can modify your codes, for example I did:
Now open your googleVis html file and it should display successfully.
In fact, any googleVis file you open from within the folder you selected will also display as you would expect.
Please note that I am using MS Internet Explorer and it asked me to activate ActiveX before I was able to view the output from above, and it was working for me.
Still, if you can not see then also please check for :