Knitr won't compile PDFs if there are plots

I just reinstalled—and updated—TinyTex. I'm trying to compile the most basic notebook as a pdf (html works fine). The code is:

title: "R Notebook"
  pdf_document: default
``` # no other code

Knitr compiles words, code, and latex equations into a pdf perfectly. As soon as I try plot, knitr can no longer compile into a pdf and can only do html. If I try compiling as a pdf it gives the error:
Package pdftex.def Error: File `Test_files/figure-latex/unnamed-chunk-1-1.pdf' not found: using draft setting.

Try deleting
# no other code
It's not an R comment because it's outside the chunk.

Yeah! Sorry! That's not actually in the code. I added it since if I didn't add the fake comment this site wouldn't show the closing triple accent mark (```) and I wanted to make it obvious that I had closed off the code block in the actual file.

Well, without the fake comment the code runs fine for me...which I recognize isn't very helpful.

No worries! Deleted all R and RStudio installations and reinstalled. Seems to be working now. No idea what was going wrong though.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.