2

I made a pakcage BayesianXXX in which I also made vignette by YYY.Rmd file in its path BayesianXXX/vignettes/YYY.Rmd.

I want to paste image in YYY.Rmd and to do so, the following Rmd script is required in the YYY.Rmd.

![title](path/to/your/image)

For example, If we made ZZZ.jpg in a image file in the inst directory, that is, BayesianXXX/inst/image/ZZZ.jpg, then how to specify its path in the code ![title](path/to/your/image)

Ref:How to import local image using knitr for markdown

Camford Oxbridge
  • 834
  • 8
  • 21

1 Answers1

2

Given your file path BayesianXXX/inst/image/ZZZ.jpg

system.file("image", "ZZZ.jpg", package="BayesianXXX")

Should work as long as the package is installed on the system (and in one of the library locations from .libPaths()).

In the YYY.Rmd, you can then use inline code:

`r paste0("![](",system.file("image", "ZZZ.jpg", package="BayesianXXX"), ")")`

Or in a chunk using cat and results='asis'

henrik_ibsen
  • 763
  • 1
  • 7
  • 16
  • 1
    Thank you very much !! Thank you!! I wanted to use the `system.file()` but I cannot come up how to execute such R script from Rmd file. I can do. Thank you !! – Camford Oxbridge May 21 '19 at 08:33