1

I'm trying to render and old rmarkdown file after I've updated R and RStudio, and all packages, but I'm getting:

Error: pandoc document conversion failed with error 99

However, the path is correct. I've rendered to HTML yesterday and everything worked fine.

```{r, echo=FALSE, fig.cap="", out.width = '50%', fig.align='center'}
knitr::include_graphics("/img/posts/que-es-un-api/mastercard-blockchain-api.jpg")
```

enter image description here

It says the path to the image is wrong, but hope you can see from image path is right.

"C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS que-es-un-api.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output que-es-un-api.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\OGONZALES\Documents\R\win-library\3.6\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\OGONZA~1\AppData\Local\Temp\RtmpSsSNeA\rmarkdown-str1340bc36ef.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 
File /img/posts/que-es-un-api/mastercard-blockchain-api.jpg not found in resource path
Error: pandoc document conversion failed with error 99
Execution halted

I've even tried to reinstall Pandoc with:

# installing/loading the package:
if(!require(installr)) { install.packages("installr"); require(installr)} #load / install+load installr

# Installing pandoc
install.pandoc()

sessionInfo:

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  htmltools_0.3.6 tools_3.6.1     yaml_2.2.0      Rcpp_1.0.2     
 [6] rmarkdown_1.14  knitr_1.24      xfun_0.8        digest_0.6.20   evaluate_0.14 
Omar Gonzales
  • 3,806
  • 10
  • 56
  • 120

2 Answers2

0

Maybe the working directory was changed. Try to include the whole path:

```{r, echo=FALSE, fig.cap="", out.width = '50%', fig.align='center'}
knitr::include_graphics("D:/omargonzalesdiaz/static/img/posts/que-es-un-api/mastercard-blockchain-api.jpg")
```
0

This issue is discussed here and here which is not a bug per se. The solution which worked for me is to use:

```{r example, echo = FALSE, out.width='80%', out.height='50%'}
knitr::include_graphics(paste0(getwd(), "/images/example_image.png"))
```

If you are working within an Rstudio project, it will help to specify the directory first:

```{r example, echo = FALSE, out.width='80%', out.height='50%'}
setwd(rprojroot::find_rstudio_root_file())
knitr::include_graphics(paste0(getwd(), "/images/example_image.png"))
```

See here and here.

user63230
  • 4,095
  • 21
  • 43
  • also https://stackoverflow.com/questions/75458365/knitrinclude-graphics-cant-find-file-if-knitr-root-dir-is-changed – user63230 Mar 10 '23 at 19:12