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

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

问题描述

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

  require(devtools)
devtools :: install_github(user / LW1949)来安装LW1949时

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

我怎样才能指出LW1949包的 import(jvamisc)部分(在NAMESPACE中)到Github而不是CRAN来找到这个依赖关系?



当然这个问题之前已经被问及过,但我没有成功搜索它(可能是因为搜索条件如此常见 - R,包,GitHub等)。我偶然发现了 Travis CI Packrat

一个>,我都没有使用过。不知道他们是否会提供帮助。我宁愿尽可能简单地修复。 (我们不是全部?



我在R Studio版本0.98.1103中使用R版本3.1.3。 / p>

解决方案

这个问题似乎很快就得到了答案,在 devtools'github repository的这个问题




套餐开发者POV:
$ b 1)do:

  devtools :: use_package(jvamisc)
devtools :: document()

在您的DESCRIPTION文件的 Imports 字段中添加依赖项。



< 2)在描述文件中手动添加一个字段Remotes:,指定github R在哪里查找包:

  #in DESCRIPTION 
进口:...,
jvamisc,
...
远程:JVAdams / jvamisc



最终用户POV:
$ b $ 1)最终用户必须拥有devtools的最新开发版本(或至少与commit#f21ca3516c相对应的版本)。你必须以某种方式'迫使他'更新他的devtools版本(我想只是把它放在安装说明中......想不到更好的方法)

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

2)重新启动R Session以卸载/重新加载devtools包3)按照惯例install_github

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

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


$ b

这些步骤和附加选项详见这个小插曲


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")

I get the message: Skipping 1 packages not available: jvamisc.

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

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?)

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

解决方案

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


Package developer POV:

1) do:

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

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

2) 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


end-user POV:

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")

2) Restart the R Session on unload/reload the devtools package

3) do the usual install_github

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

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

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

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