问题描述
有什么方法可以在 R 中包含包小插图之间的链接?我知道我可以在部分之间建立链接,例如
Is there any way I can include links between package vignettes in R? I know I can link between section, for example
# Section 1 {#section1}
My first section
# Section 2
A link to [Section 1](#section1)
但是有什么方法可以让我获得一个可点击的链接来启动另一个小插图的 HTML 文档?还是只是提供代码来启动它更容易?
But is there any way I can get a clickable link that will launch the HTML doucment of another vignette? Or is it just easier to give the code to launch it?
```r
vignette("my vignette", package = "myPackage")
```
注意我已经使用 Rmarkdown
和 knitr
生成了我的所有小插图.
Note I have generated all of my vignettes using Rmarkdown
and knitr
.
推荐答案
是的,这很简单.小插图都存储在同一目录中,因此您只需引用相应的文件名即可.drat 包 vignettes 有几个这样的例子.这是从一个小插图到另一个小插图的链接:
Yes, this is simple. Vignettes are all stored in the same directory, so you simply refer to the appropriate file name. The drat package vignettes have several examples of this. Here is a link from one vignette to the other:
This vignette deals with the first case: How to use
[drat](http://dirk.eddelbuettel.com/code/drat.html) as a package author. A
[companion vignette for package users](DratForPackageUsers.html) is available as well.
这将适用于 CRAN 和用户的机器.
This will work on CRAN and on a user's machine.
您还应该能够在用户机器上从小插图链接到文档,反之亦然,因为知道小插图存储在 library/PKGNAME/doc/
中,并且文档存储在:库/PKGNAME/html/.
You should also be able to link from vignettes to documentation, and vice versa, on a user's machine, knowing that vignettes are stored in library/PKGNAME/doc/
and documentation is stored in: library/PKGNAME/html/
.
这篇关于链接 R 包小插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!