在R-package文档(.Rd)文件中包含图像

时间:2015-01-28 10:00:45

标签: r documentation package visualization rd

我正在努力在我的包中记录可视化功能。为此,我想通过Rd文件'funcname.Rd'嵌入一个图像,它可以解释函数中使用的各种参数,如果用户去阅读包PDF手册或写'?funcname,它会弹出'在R. Something in the lines of:

Manual example

'编写R扩展'文档似乎无法解决此问题,我可以找到的唯一参考文献是this blog postthis R-devel discussion。前者与一个叫做“base64”的软件包有一个断开的链接,而后者只解决了各种替代方案,比如包括R包装晕影中的图像。如果这可能与CRAN兼容将会很棒。

有关如何处理此问题的任何建议将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:12)

未经测试,但是看看GitHub上的R源代码,看起来他们会以下列方式将图像添加到?par documentation file

 \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}}
    }

该图似乎保存在/man/figures