Search code examples
rknitrrstudior-markdownggvis

Adding ggvis plot in RMarkdown document makes knitr::kable output render incorrectly


Reproducible example below. I lose formatting on the table whenever I include a ggvis figure.

---
title: "test"
output: html_document
---

```{r setup, include=FALSE}
library(dplyr)
library(ggvis)
library(knitr)
```

The following table looks fine...

```{r echo=FALSE, results='asis'}
cars %>% kable(format = 'markdown')
```

As long as I don't include this plot below

```{r, echo=FALSE}
pressure %>%
  ggvis(x = ~temperature, y = ~pressure) %>%
  layer_bars()
```

Solution

  • This is probably related to a bug that has been fixed in the development version of ggvis. If you install the latest with devtools::install_github('rstudio/ggvis'), it should work.