error in png() Rmarkdown Word with Plumber API

46 views Asked by At

I am creating a Plumber API to generate a MS Word document with images, however, I get the following error in Swagger

"message": "\u001b[1m\u001b[33mError\u001b[39m in `png()`:\u001b[22m\n\u001b[33m!\u001b[39m unable to start png() device\n"

This is my plumber function plumber.R

#* @serializer contentType list(type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
#* @get /word
function(team){
  tmp <- getwd()
  
  render("test_report.Rmd", tmp, output_format = "word_document",
         params = list(team = team))

  readBin(paste0(tmp, ".docx"), "raw", n=file.info(paste0(tmp, ".docx"))$size)
}

This is the Rmd file test_report.Rmd

---
title: test
output: html_document
params:
  team: NA
---

`r params$team`

```{r cars}
summary(cars)
```

```{r, echo=FALSE}
 plot(pressure)
```

To run the API

library(plumber)
library(rmarkdown)
pr("plumber.R") %>%
       pr_run(port=8000)

I am using the correct serializer, as without including the plot() the API works. What is the problem?

0

There are 0 answers