4

When I try to knit a RMarkdown document with ggvis plots to Word, I get the following message from Rstudio.

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

Does there exist an elegant solution (without too much effort) to make this possible, perhaps using export_png and vg2png?

kevinykuo
  • 4,600
  • 5
  • 23
  • 31

2 Answers2

1

Here is an example:

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

The following table looks fine...
As long as I don't include this plot below

```{r, echo=FALSE, include=FALSE}
p <- pressure %>%
  ggvis(x = ~temperature, y = ~pressure) %>%
  layer_bars()
export_png(p, file = "hoge.png")
```

![](hoge.png)

enter image description here

If you will use this frequently, you can define hook.

kohske
  • 65,572
  • 8
  • 165
  • 155
  • "Error in vega_file(vis, file = file, type = "png") : Conversion program vg2png not found. " Where can I get vg2png for Windows? – skan Nov 10 '15 at 10:32
-1
  1. First go to Node JS Download page
  2. After instaling node.js, in terminal run:

    npm install vega

NSNoob
  • 5,548
  • 6
  • 41
  • 54