4

The latest version of rstudio includes the ability to generate HTML5 slide decks using some background magic similar to slidify. However, if I include

Slide With Plot
========================================================

```{r, echo=FALSE}
library(knitr)
pressure %>% ggvis(~temperature,~pressure) %>%
  layer_points() %>%
  layer_lines() 
```

I get the following results in the html output:

Slide With Plot

<!–html_preserve–>

Renderer: SVG | Canvas
Download
<!–/html_preserve–>

Knitting a regular *.Rmd file with the above code chunk would work as expected. However, knitting the Rpresentation file doesn't seem to work and I can't find any documentation as to why there is a difference in behavior.

Update: It seems like HTML output isn't yet supported for presentations despite them being HTML based. This would seem to rule out ggvis() unless one exports to svg or png via the method suggested in an answer below.

Error: Functions that produce HTML output found in document targeting revealjs output. Please change the output type of this document to HTML.

Michael Williams
  • 1,125
  • 2
  • 9
  • 13
  • Remove `results = 'svg'` and ensure that you load `knitr` before the code chunk calling `ggvis`. `ggvis` has a `knit_print` function that will automatically insert svg for the plot. – Ramnath Aug 09 '14 at 21:00
  • Thanks for the feedback Ramnath. I've made the changes suggested but get the same results. If the YAML specifies html_document as the output it will work. However with output: revealjs_presentation I get the error that I've added above. – Michael Williams Aug 10 '14 at 14:29
  • I think I know the issue with revealjs and dynamically created plots. Let me take a look. – Ramnath Aug 10 '14 at 16:12
  • I get the same issue with ioslides for what it's worth. I think it has something to do with the rMarkdown pipeline rather than reveal.js. It seems like they have a validation check in place that requires anything with html output to be exported as an html document prior to going to pandoc. I wonder if this was a condition prior to adding html presentation frameworks to the mix. I don't see an issue on for rmarkdown on github so I certainly could be wrong. – Michael Williams Aug 10 '14 at 16:57
  • `ioslides_presentation` works well for me. So I am pretty sure it is a `revealjs_presentation` issue. – Ramnath Aug 10 '14 at 22:45
  • Yes you're correct. Just confirmed that `ioslides_presentation` works for me too. – Michael Williams Aug 11 '14 at 00:57

1 Answers1

1

As the ggvis() output is in essence HTML codes, you will have to include results = 'asis' into the options of the code chunk. slidify should then render the svg properly.

yxtay
  • 506
  • 4
  • 11