knitr - 用 ggvis 将 RMarkdown 编织到 Word

标签 knitr r-markdown ggvis vega

当我尝试使用 ggvis 编织 RMarkdown 文档时绘图到 Word,我从 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

是否存在一个优雅的解决方案(无需太多努力)来实现这一点,也许使用 export_pngvg2png ?

最佳答案

这是一个例子:

```{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

如果你会经常使用这个,你可以定义钩子(Hook)。

关于knitr - 用 ggvis 将 RMarkdown 编织到 Word,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24940473/

相关文章:

htmlwidgets 并排在 html 中?

r - Knit 更改图像尺寸

r - 如何使用knitr::kable在表的底部添加注释?

r-markdown - 是否有在 r studio 中创建 python block 的快捷方式?

javascript - 使用javascript基于交互式ggplot创建过滤器选择

radio-button - 基于 R Shiny 条件面板中的单选按钮的切换图

r - ggvis 中带有 layer_paths 的 R 的工具提示

r - 是否可以在 Rstudio *.Rpres 文档中包含 ggvis() 输出?

r - 如何更改 Beamer 幻灯片中 knit::kable 的字体大小?

r - Knitr 内联 block 选项(无评估)或仅呈现突出显示的代码