当我将Rmarkdown编织到Word并包括一个使用flextable::save_as_image()
保存为图像的表格时,该函数似乎还将路径粘贴到表格上方的图像中。如何防止该路径包含在Word文档中?
这是MWE:
---
title: "MWE"
output: word_document
---
```{r include=TRUE, message=FALSE, warning=FALSE, echo=FALSE, results='asis'}
library(flextable, quietly = TRUE)
library(webshot, quietly = TRUE)
ft <- flextable( head( mtcars ) )
ft <- autofit(ft)
save_as_image(x = ft, path = "myimage.png")
knitr::include_graphics("myimage.png")
```
这是我得到的输出:
答案 0 :(得分:2)
save_as_image
返回保存图像的文件名。您可以使用invisible()
隐藏它。
invisible(save_as_image(x = ft, path = "myimage.png"))