knitr::include_graphics in bookdown, is not rendering the image and not cross referencing

Hi,

I'm trying to knit together a draft of a paper. I have completed the analysis and made all my figures in another file but just want to call the images in the manuscript write up and ultimately, I want to cross-reference the 20 plus figures in the manuscript. So, I have knitr rendering jpeg plots I created elsewhere in my saved in another folder.

I understand how to cross-reference them in theory, but I can't even get the draft to render as a pdf bc when it compiles, the tex file throws an error saying it can't find the file path of the image.

I'm including a test file I'm using to trouble should and the figure.

I'm at loss at this point. Any help would be appreciated. Here's that I've tried:

  • I thought it had to with the fact that I'm using the here package and relative file paths? But that didn't seem to be it.

  • Could it be because all of my file paths are in store in iCloud which might have some spaces? I tried to get the file to knit when I saved the image elsewhere with no spaces in the file path and that didn't work either.

  • It works when I generate the plot directly in the code chunk instead of just calling the figure with knitr::include_graphics , but I have like 20 figures so I'd prefer to just use the knitr::include_graphics function to streamline the manucscript write up and keep all of the plot generation code in a separate analysis file. Using a source could work but then I'd have to translate the original analysis file and this workflow is supposed to work because it's described here.

Here' a link to the image, the test.Rmd file, and references to compile.

Older version Cross-posted on StackOverflow

This is a personal issue, but I don't like the idea of having to click on links in your message that may lead to ???
Just take the trouble to present in your message a small example of the code that does not work.
In that way you could get more reactions.