Rmarkdown Pandoc error 99

In an RMarkdown file I use the code

![All Cases (Log Plot)](~/RStudio/dsc520/assignments/assignment04/10-all-cases-log.png)

to add a picture, which it does in the source, add the photo I want, but when I knit to HTML it comes back with the error

File ~/RStudio/dsc520/assignments/assignment04/10-all-cases-log.png not found in resource path
Error: pandoc document conversion failed with error 99

I have both my Rmd file and my png in the same path so I'm not sure why I am getting the error.

Reading your entry I imagine that you are using this type of Rmd file:

---
title: "Untitled"
author: "My name"
date: "6/17/2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Picture

This section contains a picture:

![my_picture](./mypictures/mypic.PNG)

End of document

Is this the case or are you using a different output type?

When the PNG file is indeed in the indicated folder (you did of course check the spelling and capitalization of the name of the file in the folder) this should also work for you.

The above code works for me (Windows 10). What environment are you working in?

I think there is something incorrect with my RStudio all together. I have installed rmarkdown several times, but here's an example when I run a chunk of code in an rmarkdown file everything comes out an error. Do you have any idea why that might be? I have even uninstalled and reinstalled RStudio to fix this but nothing seems to be working. In addition I have sent my files to a friend who opens them and runs them with the same errors, but then copies and pastes the code into a new Rmd file on their computer and my exact code runs without any errors. It's gotten pretty frustrating.

What you have to do anyway:

  • load the Rmd file In the editor window
  • save it as an Rmd file
  • click on the knit button

In your edit window I see that the contents of the Edit window is not saved yet:
the title is still Untitled1*.
(if I remember well one is requested to save the file when the knit button is used)

So the question: did you do this and if not: what happens when you do this. ?

Yes, I have saved my .Rmd files and ran them with the same errors. Here is the code under a saved .Rmd file. I'm unsure if it has to do with my settings or what but everything under all of my .Rmd files comes back with errors even though the code is correct.

This is before I try to knit though. When I knit simply the header it works. Then again problems come into play when I add the image, even though the path is correct. In this screenshot you can see how the image is there in my files and the path is correct but when I run the code it gives me a weird error saying there's an unexpected character. This is before I attempt to knit it as well.

Are you able to include the whole Rmd file by copying it into a reply?
As a picture as you have done before but now all lines in one picture or as text.
You can use four backticks before and after the text to make it more readable.

---
title: "Test"
author: "Laura H."
date: "6/16/2020"
output: html_document
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)```

## R Markdown

![Image](~/RStudio/dsc520/assignments/assignment04/10-all-cases-log.png)

And when I run that in Rmarkdown every single line comes back with an error message. And when I knit it I get the error message,

Error: pandoc document conversion failed with error 99

But I know that is the correct path, and the files are in the same directory too.

I can reproduce your error.
I get the same when I select all lines in the Rmd file and enter Ctrl+Enter.
However you can not run an Rmd file; only some or all R chunks and not lines outside these chunks/
So I think that settles the Run issue (?)

Two suggestions for the pandoc error

  • what happens if you leave out the path? So only specify
    ![Image](10-all-cases-log.png)
  • what result do you get if you make a chunk with only print(getwd())
1 Like

It said "(No image at path 10-all-cases-log.png)"
and for print(getwd)

> print(getwd)
function () 
.Internal(getwd())
<bytecode: 0x000001d23e8cbd80>
<environment: namespace:base>

I meant print(getwd())

My bad, I'm sorry here is the output

> print(getwd())
[1] "C:/Users/Laura/Documents"
> setwd("~/RStudio/dsc520/assignments/assignment04")
> print(getwd())
[1] "C:/Users/Laura/Documents/RStudio/dsc520/assignments/assignment04"

I set this as my working directory so now I should be able to just use the image because it is stored in the assignment04 folder with my .Rmd file

This is the result when enter the statement in the console I suppose (?)

What do you see if you replace the ![Image] ... statement with the R chunk

```{r}
print(getwd())
```

?

I ran the code

print(getwd())

and got the output

[1] "C:/Users/Laura/Documents"

But then to reset my working directory to my exact folder I ran

> setwd("~/RStudio/dsc520/assignments/assignment04")
> print(getwd())

And got the output

[1] "C:/Users/Laura/Documents/RStudio/dsc520/assignments/assignment04"

The path to my .png file is: "C:/Users/Laura/Documents/RStudio/dsc520/assignments/assignment04/10-all-cases-log.png"

I am unable to post new comments anymore today, but know that I did create an r chunk. The ```{r} portion just didn't show up when I printed it on here. That's how I ran it, and it changed. And I set the working directory to ("~/RStudio/dsc520/assignments/assignment04"), and tried to use the code

![Image](10-all-cases-log.png)

Then I knit it and it went through. Thank you so much for your patience with me!

I understand that you did not create an R chunk with the statement as requested. Okay.

Another question:

  • what happens when you set first the working directory in your interactive session
setwd("~/RStudio/dsc520/assignments/assignment04")

and then click the knit button for the Rmd file with the ![Image] ... statement ?

Nice that your problems are solved.

Problems with paths are more easily avoided by working with RStudio projects.
For this case you could have made a project in

~/RStudio/dsc520/assignments/assignment04

If you then open the project the working directory is automatically set and all files are by default saved in that directory. Check it out: it is very convenient.

1 Like

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