Knitting RMarkdown with ggvis to Word

家住魔仙堡 提交于 2020-01-01 11:59:10

问题


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?


回答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)

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




回答2:


  1. First go to Node JS Download page
  2. After instaling node.js, in terminal run:

    npm install vega



来源:https://stackoverflow.com/questions/24940473/knitting-rmarkdown-with-ggvis-to-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!