r-markdownhugoblogdown

R Markdown - Unable to find image at path


I saved an image at the path ./static/static/images/air_quality.png. When I am adding this image to my R Markdown file, I keep getting this message (No image at path static/images/air_quality.png).

Not sure what the issue is.

Note: The path static/images/air_quality.png given in the R markdown file is correct.

My question is, why is the image not being recognized?

Screenshot below: enter image description here


Solution

  • This pandoc markdown syntax ![air quality](/static/images/air_quality.png) is only working in markdown files. As I am using R Markdown, I have to change this code to:

    ```{r air-quality, echo=FALSE, out.width = '100%'}
    knitr::include_graphics("/static/images/air_quality.png", error = FALSE)
    ```
    

    error = FALSE in include_graphics() is important as without that argument, it throws the same error.