I like the new knit button where you can select Knit Directory > Project Directory. BUT I can't figure out what to type in the console to recreate this... I want to know so I could put this in a Makefile, for example. I think the Knit button using rmarkdown::render, but from reading the docs, I still cannot figure out how to replicate Knit Directory > Project Directory from the console.
It works by setting the knit_root_dir
parameter to rmarkdown::render
. You can set this yourself to the project root in your Makefile to get the same behavior.
https://www.rdocumentation.org/packages/rmarkdown/versions/1.6/topics/render
OK, helpful to get me started. So I can replicate what the button now does. But I want to also use the output_dir
argument to put the rendered docs and figs in my doc
directory, while the .Rmd
I render from, lives in the src
directory. I can do this, but it seems when you use knit_root_dir
on its own, you get relative paths to figures in the rendered .md
file, while when you use knit_root_dir
& output_dir
it switches back to absolute paths. Very frustrating... As then when, for example you put the rendered docs on Github, you can't see the figures...
I can do exactly what I want when I use the ezknitr
package... it would be nice if this could be done through the more widely-used rmarkdown
package... Perhaps I need to open an issue in that dev repo...