【问题标题】:RMarkdown flextable: Does as_image() work with rmarkdown::render()?RMarkdown flextable:as_image() 是否与 rmarkdown::render() 一起使用?
【发布时间】:2022-08-06 03:43:43
【问题描述】:

我想将图像插入到使用 knit 按钮时完美工作的弹性表中。但是,我需要通过调用rmarkdown::render(input = \"path_to_file/file.Rmd\") 来执行代码。

这会生成以下错误消息:

save_kable(x = x, file = temp_png, ...) 中的错误:
缺少参数“x”,没有默认值

这是 YAML:

---
output: 
    officedown::rdocx_document
---

这是一个可重现的例子:

```{r}
library(officer)
library(flextable)
library(officedown)

img.file <- file.path( R.home(\"doc\"), \"html\", \"logo.jpg\" )

myft <- flextable( head(iris))

myft <- compose(myft, i = 1:3, j = 1,
  value = as_paragraph(as_image(src = img.file, width = .20, height = .15)))

ft <- autofit(myft)
ft
```
  • 我无法重现,它会生成预期的文档。你可以添加你的会话信息吗?我不明白为什么错误中提到了save_kable...

标签: r r-markdown render flextable officedown


【解决方案1】:

我测试了你的代码,它运行良好。正如 David Gohel 所提到的,save_kable 错误并不是指您的可重现示例。也许您的 Rmd 中还有其他代码行。导致问题的文件。

【讨论】:

  • 感谢您的回复,您是对的。我之前包含了library(kableExtra),这是导致问题的原因。 @DavidGohel 添加此库时,出现save_kable 错误。
猜你喜欢
  • 2021-11-20
  • 2021-06-15
  • 1970-01-01
  • 2023-02-05
  • 1970-01-01
  • 1970-01-01
  • 2019-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多