Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build R package from GitHub?

Tags:

github

r

I try to build fork of R package from github (this fork has a fresh bugfix). I am able to build AND install the package from 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.

I tried to look for funciton like build_github, unfortunatelly there is none. How do I do it?

like image 748
Tomas Avatar asked Sep 15 '14 10:09

Tomas


People also ask

How do I download a package from GitHub?

On GitHub, navigate to the main page of the repository. Click the Clone or download button located under the repository name. A dropdown is displayed. Click on Download ZIP and save the repository as a zip file to your system.


2 Answers

github has help documentation on how to fork a repository. 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. If you are running git from a command line, type

git clone [email protected]:whatever-the-link-is-in-the-SSH-clone-url-textbox

github cloning screenshot

Once you have a local copy of the repository, in R you do

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. Download, unzip, then build in R as above.

like image 76
Richie Cotton Avatar answered Sep 29 '22 12:09

Richie Cotton


It's old question and a lot changes since 2014. Now the workhorse is remotes package.

If you want installable package there is one created in your temp directory.

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())). You should see folder [fileXXXXXXXX] which should contain rredis_1.6.9.tar.gz file. This is what you need.

unlink(tmp_lib, recursive=TRUE) cleanup your temp directory.

like image 21
Marek Avatar answered Sep 29 '22 12:09

Marek