【问题标题】:flextable::save_as_image() includes path to image when Rmarkdown knit to Wordflextable::save_as_image() 包括 Rmarkdown 编织到 Word 时的图像路径
【发布时间】:2020-06-17 19:54:39
【问题描述】:

当我将 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")
```

这是我得到的输出:

【问题讨论】:

    标签: r flextable


    【解决方案1】:

    save_as_image 返回您保存图像的文件名。你可以用invisible()隐藏它。

    invisible(save_as_image(x = ft, path = "myimage.png"))
    

    【讨论】:

      猜你喜欢
      • 2014-09-16
      • 2019-11-02
      • 1970-01-01
      • 2021-02-01
      • 2019-02-05
      • 2021-03-04
      • 2016-10-07
      • 1970-01-01
      • 2021-09-15
      相关资源
      最近更新 更多