How to include graphics when using tar_render()
? Error: Cannot find the file(s)
#134
Replies: 2 comments 2 replies
-
Seems similar to #116 (comment). Experimenting with regular Markdown syntax and |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response and suggestions! I managed to get the following to work both with Ideally, however, I would like the I've created a GitHub repo that should help with the reprex: rtargets-reprex. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I would like
tar_render()
to render an.rmd
that includes several external graphics that are stored in a directory in the same location where the.rmd
is. However, I keep getting the errorCannot find the file(s): "figures/example.png"
.The way I am currently running this is:
.rmd
is stored in the directory,./docs/
, while figures are stored in./docs/figures
./docs/figures
in my_targets.R
using:tar_render()
, using the following command:.rmd
, I use tar_read in the yaml header to call the path to the target,fig_dir
(see below).knitr::include_graphics(file.path(params$ext_figures, "example.png"))
Appreciate this is quite a long-winded solution, but it was important that I was (i) able to track the dependencies going into the
.rmd
, as in more complicated cases, I will be using the outputs of other processes as input to my.rmd
and (ii) still able to knit the.rmd
using RStudio's knit button. The above solution allows me to knit the.rmd
without issues. But unfortunately it doesn't seem to work withtar_render()
. Do you have any suggestions as to how to resolve this?Beta Was this translation helpful? Give feedback.
All reactions