在 R 包文档 (.Rd) 文件中包含图像 [英] Including images in R-package documentation (.Rd) files

查看:25
本文介绍了在 R 包文档 (.Rd) 文件中包含图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在我的一个包中记录一个可视化功能.为此,我希望通过 Rd 文件funcname.Rd"嵌入一个图像,该图像可以解释函数中使用的各种参数,如果用户阅读包手册 PDF 或写入?funcname",该图像会弹出' 在 R. 中的一些东西:

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 似乎没有解决这个问题,我能找到的唯一参考资料是 这篇博文这个 R-devel 讨论.前者与一个名为base64"的包的链接断开了,而后者只解决了各种替代方案,例如将图像包含在 R 包小插图中.如果这可以与 CRAN 兼容,那就太好了.

'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!

推荐答案

未经测试,但是查看 GitHub 上的 R 源代码,似乎他们将图像添加到 ?par 文档文件,格式如下:

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

该图似乎保存在 /man/figures 中.

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

有关详细信息,请参阅 编写 R 扩展部分 关于主题.

For more details see the Writing R Extensions section on the topic.

这篇关于在 R 包文档 (.Rd) 文件中包含图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆