R-Markdown html Document doesnt show image

I want to use knit and create a html document with an image but I get the same error all the time. maybe someone knows the solution (MacOS). I have the same working directory so what is the problem? The rmd file shows my image but when I want to create the html document I get the error...Do I need any package maybe?

my code in the rmd file:


R Markdown:
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS SMA.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output SMA.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:cerulean' --include-in-header /var/folders/vk/lt8vkm6d0xl2w5d4m_g2tbvw0000gn/T//RtmpXRW18j/rmarkdown-str1fe22cf1cfd6.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --variable code_folding=hide --variable code_menu=1
pandoc: Could not fetch ~/Downloads/SMA/test1.png
~/Downloads/SMA/test1.png: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted

You got this error because the image is not in the local working directory and is your home folder. Pandoc does not know where to find it with ~.

I think you should use full path by expanding your image file path so that pandoc gets it.

Also, you can use knitr::include_graphics to include images in Rmarkdown.

1 Like

Thank you for the answer! But what do you mean exactly with

[quote="cderv, post:2, topic:41629"]
expanding your image file path

Look at


This will create a full path to your image.

Alright, finally I fixed it. Thank you very much for your tips!

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.