简体   繁体   English

如何从GitHub构建R包?

[英]How to build R package from GitHub?

I try to build fork of R package from github (this fork has a fresh bugfix ). 我尝试从github构建R包的分支(此分支具有一个新的bugfix )。 I am able to build AND install the package from github: 我能够从github 构建和安装软件包:

require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)

However, this doesn't produce installable package - or does it? 但是,这不会产生可安装的软件包-还是? I need to install this package on 15 machines so I prefer to build the package once and then copy and install it on the other machines. 我需要在15台计算机上安装此软件包,因此我希望先构建该软件包,然后将其复制并安装到其他计算机上。

I tried to look for funciton like build_github , unfortunatelly there is none. 我试图寻找像build_github这样的build_github ,不幸的是没有。 How do I do it? 我该怎么做?

github has help documentation on how to fork a repository . github提供了有关如何派生存储库的帮助文档。 It sounds like you've done the first part. 听起来您已经完成了第一部分。 Now you just need to clone the repository. 现在,您只需要克隆存储库。 That means taking a copy for your local machine so you can work on it. 这意味着要为本地计算机制作一份副本,以便您可以在其上进行操作。 The buttons you want are on the right. 您想要的按钮在右侧。 Clone in desktop is for when you use the Github desktop software . 在桌面上克隆适用于您使用Github桌面软件的情况 If you are running git from a command line, type 如果您从命令行运行git,请输入

git clone git@github.com:whatever-the-link-is-in-the-SSH-clone-url-textbox

github克隆截图

Once you have a local copy of the repository, in R you do 一旦有了存储库的本地副本,就可以在R中执行

library(devtools)
build("path/to/package/root")

I thought you wanted to actually work on the package. 我以为您想在包装上进行实际工作。 If you just want to download the source, there's a "Download ZIP" button right underneath the clone options. 如果您只想下载源代码,则在克隆选项下方有一个“下载ZIP”按钮。 Download, unzip, then build in R as above. 下载,解压缩,然后按上述方法在R中构建。

It's old question and a lot changes since 2014. Now the workhorse is remotes package . 自2014年以来,这是一个古老的问题,并且发生了很多变化。现在,最主要的功能是遥控器套件

If you want installable package there is one created in your temp directory. 如果要安装软件包,则在temp目录中创建一个软件包。

I usually don't want install so I create temporary library: 我通常不想安装,因此我创建了临时库:

dir.create(tmp_lib <- "tmp_lib")
.libPaths(c(tmp_lib,.libPaths()))
.libPaths()

But you can skip that if not needed, now standard: 但是,如果不需要,现在可以将其跳过:

require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)

Now navigate to your temp location given by tempdir() (in Windows shortcut is: shell.exec(tempdir()) ). 现在,导航到tempdir()给定的临时位置(在Windows快捷方式中为: shell.exec(tempdir()) )。 You should see folder [fileXXXXXXXX] which should contain rredis_1.6.9.tar.gz file. 您应该看到文件夹[fileXXXXXXXX],其中应包含rredis_1.6.9.tar.gz文件。 This is what you need. 这就是你所需要的。

unlink(tmp_lib, recursive=TRUE) cleanup your temp directory. unlink(tmp_lib, recursive=TRUE)清理您的临时目录。

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

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