0

I want to insert an image into a flextable which works perfectly when using the knit button. However, I need to execute the code by calling rmarkdown::render(input = "path_to_file/file.Rmd").

This generates the following error message:

Error in save_kable(x = x, file = temp_png, ...) :
argument "x" is missing, with no default

This is the YAML:

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

And this is a reproducable example:

```{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
```
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I am not able to reproduce, it generates the expected document. Can you add your session info? I don't understand why `save_kable` is mentioned in the error... – David Gohel Jul 08 '22 at 16:50

1 Answers1

2

I tested your codes and it worked fine. As David Gohel mentioned, save_kable error does not refer to your reproducable example. Maybe you have other code lines remaining in your Rmd. file that cause the issue.

enter image description here

enter image description here

M. white
  • 80
  • 7
  • Thanks for the response and you were right. I had included `library(kableExtra)` before which was causing the problem. @DavidGohel When adding this library, the `save_kable` error occurs. – Sophie Wupper Jul 20 '22 at 13:07