简体   繁体   English

在构建和重新加载R包时显示vignettes链接

[英]showing vignettes link upon building and reloading an R package

I have created a vigentte folder for an R package I am developing by running the code devtools::use_vignette("my-vignette") . 我通过运行代码devtools::use_vignette("my-vignette")为我正在开发的R包创建了一个vigentte文件夹。 I am using Rmarkdown and knitr packages. 我正在使用Rmarkdownknitr包。

When I build & reload the package, I don't get a hyperlink for the title of the Rmarkdown file (which contains the long-form documentation of the package) in the documentation page of the package. 当我构建并重新加载包时,我没有在包的文档页面中获得Rmarkdown文件的标题的超链接(其中包含包的长格式文档)。 I do get hyperlinks for the DESCRIPTION file of the package as well as the help pages of the documented functions but not the hyperlink that should direct people to the Rmarkdown document. 我确实获得了包的DESCRIPTION文件的超链接以及所记录函数的帮助页面,但没有获取应该将人们引导到Rmarkdown文档的超链接。 I am wondering why and what should I do to get a hperlink for the long-form documentation of the package in a similar way that I get it for the help pages for the functions used in the package? 我想知道为什么以及我应该怎么做才能以类似的方式获取包的长格式文档的hperlink,以获得包中使用的函数的帮助页面?

Daragh, Daragh,

Can you provide more detail on the error you are seeing? 您能否提供有关您所看到的错误的更多详细信息? If the code is posted on github or you have a specific error then we may be able to help further - if not then the best advice I can give is to check out Hadley Wickam's "R Packages" book online - it is a great reference: 如果代码是在github上发布的,或者你有特定的错误,那么我们可以进一步提供帮助 - 如果没有,那么我能给出的最好的建议就是在线查看Hadley Wickam的“R Packages”一书 - 这是一个很好的参考:

http://r-pkgs.had.co.nz/ http://r-pkgs.had.co.nz/

that will at least give you a good sense of how to build the vignettes. 这至少可以让你很好地了解如何建立小插曲。

http://r-pkgs.had.co.nz/vignettes.html http://r-pkgs.had.co.nz/vignettes.html

From the online book by Hadley Wickham referenced above... 来自上面引用的Hadley Wickham的在线书籍......


CRAN notes CRAN注意到

Note that since you build vignettes locally, CRAN only receives the html/pdf and the source code. 请注意,由于您在本地构建了vignet,因此CRAN只接收html / pdf和源代码。 However, CRAN does not re-build the vignette. 但是,CRAN不会重新构建小插图。 It only checks that the code is runnable (by running it). 它只检查代码是否可运行(通过运行它)。 This means that any packages used by the vignette must be declared in the DESCRIPTION. 这意味着必须在DESCRIPTION中声明晕影使用的任何包。 But this also means that you can use Rmarkdown (which uses pandoc) even though CRAN doesn't have pandoc installed. 但这也意味着你可以使用Rmarkdown(使用pandoc),即使CRAN没有安装pandoc。

Common problems: 常见问题:

The vignette builds interactively, but when checking, it fails with an error about a missing package that you know is installed. 插图以交互方式构建,但在检查时,它会因为您知道已安装的缺少包的错误而失败。 This means that you've forgotten to declare that dependency in the DESCRIPTION (usually it should go in Suggests). 这意味着您忘记在DESCRIPTION中声明该依赖项(通常应该在Suggests中)。

Everything works interactively, but the vignette doesn't show up after you've installed the package. 一切都以交互方式工作,但在安装软件包后,小插图不会显示出来。 One of the following may have occurred. 可能发生了下列情况之一。 First, because RStudio's “build and reload” doesn't build vignettes, you may need to run devtools::install() instead. 首先,因为RStudio的“构建和重新加载”不会构建小插图,所以您可能需要运行devtools :: install()。 Next check: 下一步检查:

  • The directory is called vignettes/ and not vignette/. 该目录称为vignettes /而不是vignette /。
  • Check that you haven't inadvertently excluded the vignettes with .Rbuildignore 检查您是否没有无意中使用.Rbuildignore排除了晕影
  • Ensure you have the necessary vignette metadata. 确保您具有必要的晕影元数据。
  • If you use error = TRUE, you must use purl = FALSE. 如果使用error = TRUE,则必须使用purl = FALSE。

You'll need to watch the file size. 您需要查看文件大小。 If you include a lot of graphics, it's easy to create a very large file. 如果包含大量图形,则可以轻松创建非常大的文件。 There are no hard and fast rules, but if you have a very large vignette be prepared to either justify the file size, or to make it smaller. 没有硬性和快速的规则,但是如果你有一个非常大的小插图准备要么证明文件大小合理,要么使它变小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM