1

My file tree looks like this:
--forecast
----report
------forecast.rmd
----plots
-------forecasts
--------2021-08-05
----------apps-approved-Credit Card.png

I set the option at the beginning

knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())

And the code chunk to import the image:

knitr::include_graphics("forecast\\plots\\forecasts\\2021-08-05\\apps-approved-Credit Card.png"))

When I execute the above code chunk, I get the expected result:

[1] "forecast\\plots\\forecasts-training\\2021-08-05\\apps-approved-Credit Card.png"
attr(,"class")
[1] "knit_image_paths" "knit_asis"  

However, when kniting the document, I get the following errors

[WARNING] Could not fetch resource 'forecast\plots\forecasts-training\2021-08-05\apps-approved-Credit%20Card.png': PandocResourceNotFound "forecast\plots\forecasts-training\2021-08-05\apps-approved-Credit Card.png"

stefan
  • 90,330
  • 6
  • 25
  • 51
Blake Shurtz
  • 321
  • 3
  • 13

1 Answers1

0

My own way to solve this is based on the post here: https://github.com/yihui/knitr/issues/1825

Basically, I'm wrapping the directory in normalizePath().

knitr::include_graphics(normalizePath(paste0(training_directory, "/apps-received-Credit Card.png")))
Blake Shurtz
  • 321
  • 3
  • 13