创建依赖于位于 GitHub 上的另一个 R 包的 R 包 [英] Create an R package that depends on another R package located on GitHub

查看:27
本文介绍了创建依赖于位于 GitHub 上的另一个 R 包的 R 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 GitHub 上创建一个 R 包,LW1949,它依赖于 GitHub 上的另一个 R 包,jvamisc.当我尝试使用

I am creating an R package on GitHub, LW1949, that depends on another R package on GitHub, jvamisc. When I try to install LW1949 using

require(devtools)
devtools::install_github("user/LW1949")

我收到消息:跳过 1 个不可用的包:jvamisc.

如何将 LW1949 包(在 NAMESPACE 中)的 import(jvamisc) 部分指向 Github 而不是 CRAN 以找到此依赖项?

How can I point the import(jvamisc) part of the LW1949 package (in NAMESPACE) to Github instead of CRAN to find this dependency?

这个问题以前肯定有人问过,也有人回答过,但我没有成功搜索到它(可能是因为搜索词太常见了——R、包、GitHub 等).我确实偶然发现了 Travis CIPackrata>,我都没用过.不知道他们是否会提供帮助.我更喜欢尽可能简单的修复.(我们不都是这样吗?)

Surely this question has been asked and answered before, but I was not successful searching for it (perhaps because the search terms are so common - R, package, GitHub, etc.). I did stumble across Travis CI and Packrat, neither of which I've used. No idea if they would help. I would prefer as simple a fix as possible. (Wouldn't we all?)

我在 R Studio 0.98.1103 版中使用适用于 Windows 的 R 3.1.3 版.

I'm using R version 3.1.3 for Windows in R Studio Version 0.98.1103.

推荐答案

这个问题似乎在最近才得到解答,在 这个问题 devtools 的 github 存储库.

This question seems to have been answered quite recently, addressed in this issue of the devtools' github repository.

包开发者 POV:

  1. 做:

usethis::use_package("jvamisc")
devtools::document()

在描述文件的 Imports 字段中添加依赖项.

to add the dependency in the Imports field of your DESCRIPTION file.

  1. 手动添加字段远程:"在描述文件中,指定 github R 应该在何处查找包:

  1. manually add a field "Remotes:" in the DESCRIPTION file, specifying where on github R should look for the package:

#in DESCRIPTION
Imports: ...,
  jvamisc,
  ...
Remotes: JVAdams/jvamisc

最终用户 POV:

  1. 最终用户必须拥有最新的 devtools 开发版本(或至少与提交 #f21ca3516c 对应的版本).你必须以某种方式强迫他"更新他的 devtools 版本(我想只是把它放在安装说明中......想不出更好的方法)

  1. the end user has to have the latest development version of devtools (or at least the one corresponding to commit #f21ca3516c). You have to somehow 'force him' to update his devtools version (I guess just put this in the installation instructions... Can't think of a better way)

devtools::install_github("hadley/devtools", ref = "f21ca3516c")

  • 在卸载/重新加载 devtools 包时重新启动 R 会话.

  • Restart the R Session on unload/reload the devtools package.

    做通常的install_github:

    require(devtools)
    devtools::install_github("user/LW1949")
    

  • 我猜这个功能迟早会被添加到 devtools 的 CRAN 版本中,所以用户不需要获取 dev 版本,他会直接进入第 3 步).

    I guess this functionality will be added sooner or later to the CRAN version of devtools, so there will be no need for the user to fetch the dev version and he would go directly to step 3).

    此小插图中详细介绍了这些步骤和其他选项.

    The steps and additional options are detailed in this vignette.

    这篇关于创建依赖于位于 GitHub 上的另一个 R 包的 R 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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