Including images in R-package documentation (.Rd) files

三世轮回 提交于 2019-12-09 15:50:15

问题


I am working to document a visualization function in a package of mine. For this purpose I would like to have an image embedded through the Rd-file 'funcname.Rd' that could explain various parameters utilized in the function, and which would pop up if user goes to read the package manual PDF or writes '?funcname' in R. Something in the lines of:

'Writing R extensions'-document doesn't seem to address this issue, and the only references I could find were this blog post and this R-devel discussion. The former has a broken link to a package called 'base64' and the latter only addresses various alternatives like including the images in R package vignettes instead. It would be great if this could be CRAN-compatible.

Any advice on how to approach this issue would be appreciated, thanks!


回答1:


Untested, but look at the R source on GitHub, it would appear they add an image to ?par documentation file in the following manner:

 \item{\code{mai}}{A numerical vector of the form \code{c(bottom,
        left, top, right)} which gives the margin size specified in
      inches.\cr
      \if{html}{\figure{mai.png}{options: width="35\%" alt="Figure: mai.png"}}
      \if{latex}{\figure{mai.pdf}{options: width=7cm}}
    }

The figure appears to be saved in /man/figures.



来源:https://stackoverflow.com/questions/28189327/including-images-in-r-package-documentation-rd-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!