Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Pandoc does not retrieve the image file?

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 folders including images (some manually added by myself), figures, cache and a knitHtml folder which included final .html file. I recently downloaded RStudio version 0.98.894 (preview release) because I wanted to use more features. Now, when I click KnitHtml I get following error:

pandoc.exe: Failed to retrieve C:/Users/durraniu/Documents/Trajectory1/images/vissim-view.png InvalidUrlException "C:/Users/durraniu/Documents/Trajectory1/images/vissim-view.png" "Invalid scheme" Error: pandoc document conversion failed with error 61

I copied all the images including the vissim-view.png as indicated above, from the images folder to the knitHtml folder and clicked the button again. This time it gave the same error related to image file which R would create i.e a plot. How to resolve this?

like image 936
umair durrani Avatar asked Jun 06 '14 22:06

umair durrani


People also ask

How do I add an image to a RMD file?

To insert an image, you can also use an R code chunk. --- title: "R Markdown Tips and Tricks" output: html_document --- You can also insert an image using R code: ```{r} knitr::include_graphics("img/rmarkdown_hex. png") ``` The image looks smaller by default though.

Does Pandoc need LaTeX?

By default, pandoc will use LaTeX to create the PDF, which requires that a LaTeX engine be installed (see --pdf-engine below). Alternatively, pandoc can use ConTeXt, roff ms, or HTML as an intermediate format.

Does Rmarkdown use Pandoc?

A recent version of Pandoc (>= 1.12. 3) is required to use the rmarkdown package. RStudio also automatically includes this so you do not need to download Pandoc if you plan to use rmarkdown from the RStudio IDE. If not using the RStudio IDE, you'll need to install Pandoc for your platform.

How do I use Pandoc markdown PDF?

Generating PDF from Markdown with Pandoc There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.


2 Answers

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)
like image 105
Megatron Avatar answered Sep 20 '22 12:09

Megatron


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.

like image 42
Tom Avatar answered Sep 22 '22 12:09

Tom