'How to fix pandoc (error 1) in rmarkdown for html output?

I'm using pandoc version 2.18 and R version 4.1.3. I'm using rmarkdown to knit a document into an html format, but repeatedly receive the following error:

pandoc.exe: \\: openBinaryFile: invalid argument (Invalid argument)
Error: pandoc document conversion failed with error 1
Execution halted

I used the following code. HOWEVER, when I change the output type to word_document, it runs without any problem.

---
title: "Test_outputtype"
output: 
  html_document
---

```{r setup, include=FALSE}```

### ggplot2

```{r}
library(ggplot2)

ggplot(mpg, aes(displ, hwy)) +
  geom_point() + geom_smooth()```

I saw a couple of similar problems with pandoc error 1 that were resolved by changing the working directory to the c drive but I've already done that. This problem extends to other packages that rely on pandoc, such as flexdashboard.

Any ideas for solutions or workarounds would be greatly appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source