如何在二进制R包中包含HTML小插图 [英] How to include an HTML vignette in a binary R package

查看:82
本文介绍了如何在二进制R包中包含HTML小插图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个R包供内部使用,还添加了一些小插曲。当我使用 devtools :: install(build_vignettes = TRUE)时,所有小插图都已正确安装在我的计算机上。但是为了将软件包分发给其他人,我想生成一个Windows二进制文件。

I wrote an R package for internal purposes and also added some vignettes. When I use devtools::install(build_vignettes = TRUE), all vignettes are installed properly on my machine. But in order to distribute the package to colleages, I would like to generate a windows binary.

但是当我从RStudio Build窗格中使用 Build binary package 时,从生成的二进制文件中安装软件包时,小插图将不会显示。我认为在构建二进制软件包之前,可以将小插图从 doc 移到 inst / doc ,但这需要

But when I use Build binary package from the RStudio Build pane, the vignettes will not show up when the package is installed from the generated binary. I figured that I could move the vignettes from doc to inst/doc before building the binary package, but this needs to be done manually whenever a vignette changes.

来自 R CMD INSTALL --help 我无法确定是否存在

From R CMD INSTALL --help I could not figure if there is an option to include building the vignettes.

有没有比将文件从 doc 手动复制到的更好的选择了? inst / doc

Is there any better option available than manually copying the files from doc to inst/doc?

我已经尝试过 devtools :: build_vignettes()。这是控制台中的输出:

I already tried devtools::build_vignettes(). This is the output in the console:

> devtools::build_vignettes()
Building archivR vignettes
Moving vig1.html, vig2.html, vig1.R, vig2.R to doc/
Copying vig1.Rmd, vig2.Rmd to doc/
Building vignette index

它表示文件已复制到 doc / 。它们不会出现在 inst / doc 中。

It says that the files are copied to doc/. They do not appear in inst/doc.

推荐答案

仅供参考:

最可靠的方法是构建源程序包(.tar.gz文件),然后使用命令工具而非RStudio来构建二进制文件。如果您在可以找到源包的目录中,则可以在命令行中使用以下命令(假设R在您的PATH中):

The most robust way is to build a source package (.tar.gz file) and then use the command tools instead of RStudio to build the binary. If you're in the directory where the source package can be found, you can use the following command at the command line (provided R is in your PATH):

R CMD INSTALL --build pkgname_x.y.z.tar.gz

pkgname_x.yztar.gz 包含源软件包的tar文件的名称。

with pkgname_x.y.z.tar.gz the name of the tar file containing the source package.

请注意,您应该创建如果要正确添加小插图,请先从源程序包进行构建,然后从源程序包进行构建。

Note that you should create the source package first and build from the source package if you want to have the vignettes added correctly.

这篇关于如何在二进制R包中包含HTML小插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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