Why Pandoc does not retrieve the image file?

前端 未结 4 978
时光说笑
时光说笑 2021-02-01 23:33

On RStudio version 0.98.501 I had a long .Rmd file which was easily converted to html once I clicked KnitHtml button. The Knitting process, as I understand, created several fold

相关标签:
4条回答
  • 2021-02-01 23:48

    @Yihui's comment above was the answer that worked for me, and it's not a current answer here, so I'm adding it:

    "Never use absolute paths unless you absolutely have to. Use relative paths whenever you can. Put your image under the same directory as the Rmd file, and use ![](vissim-view.png)."

    Using a relative path worked for me where an absolute path did not.

    0 讨论(0)
  • 2021-02-01 23:53

    I encountered a similar error like this: pandoc.exe: Could not find data file ProjectPart1_files/figure-html/sample_Mean_versus_Theoretical_Mean-1.png Error: pandoc document conversion failed with error 97

    And one sentence from this page solved my problem.

    "If you run into problems with cached output you can always clear the knitr cache by removing the folder named with a _cache suffix within your document’s directory."

    When the error occurred, there exactly existed a folder with name like "ProjectPart1_cache" in the working directory. After I deleted it, the error was removed.

    0 讨论(0)
  • 2021-02-02 00:01

    Sadly, Jonathan's answer in the comments worked for me. I added:

    <!-- rmarkdown v1 -->
    

    To my document, and it did the trick. He claims that this is because Pandoc on Windows is not great at handling paths.

    If someone else would write a better answer, I will gladly erase this one.

    0 讨论(0)
  • 2021-02-02 00:05

    While there are multiple correct solutions above, I'd like to add that a common cause of this error is syntactical, when the author accidentally wraps the file name in the markdown in quotes:

    ![my image]("my_image.png")
    

    This will result in pandoc being unable to locate the file. I find this mistake to be easy to make in knitr, since we are intertwining R scripts with markdown.

    The correct way to insert the image is:

    ![my image](my_image.png)
    
    0 讨论(0)
提交回复
热议问题