Hello,
can some one help me to define input figure folder in rmarkdown as global option? I mean I have a figures folder inside the project directory where the Rmd file is stored. I can read figure if the figures are also stored in the same place. But for organisational purpose, I like the input figures like logo, titlegraphic etc inside a separate folder. I want to define this folder as input figure folder ( simmilar to using grpahicspath in latex). Is there a way?
Hello @nithinmkp,
I am not quite sure what you trying to do, but if you are willing to specify the path in your code you could do something like:
knitr::include_graphics('./myproj/images/logo.PNG',error=F)
I must confess that I have to determine the exact path by trial and error: mostly I temporarily include a getwd()
statement in the code to know 'where I am'.
Hope this helps.
There are several helper to handle file path within a project. The here package can be useful to derive path from the root directory of a project
You can then use knitr::include_graphics
or you can then create a wrapper function to include you image by name and the path would be prepended based on a variable.
Best way to achieve all these is to define your path and helper function in a setup chunk to use in your doc. There is no knitr option I believe for input file path of image - this is usually handle by the user.
Beware of using absolute path though when generating non standalone HTML document - your HTML doc must know how to reach the image. This is why often the images are place in a folder relative to the site root. For self_contained document this would be ok though.
I let you try
That helped. Thanks a lot. I was using here but not in a proper way. But I guess it should be a feature in later versions of knitr.
Thanks
That was a useful reminder Christophe. Thanks
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.