“A Helpful Way to Install R Packages Hosted on GitHub”

Travis-CI Build Status CRAN Version CRAN Downloads Coverage Status


There is an install_github function to install R packages hosted on GitHub in the devtools package. But it requests developer’s name.


The githubinstall package provides a function githubinstall. It does not need developer’s name.


The package also provides some helpful functions for R packages hosted on GitHub.

1 Overview

Various people in the world create a growing number of R packages. A part of the cause of it is the devtools package that makes it easy to develop R packages [1]. The devtools package not only facilitates the process to develop R packages but also provides another way to distribute R packages.

When developers publish R packages that created by them, they commonly use CRAN [2]. You can install packages that are available on CRAN using install.package(). For example, you can install dplyr package as follows:


The devtools package provides install_github() that enables installing packages from GitHub.


Therefore, developers can distribute R packages that are developing on GitHub. Besides, there are some developers that they have no intention to submit to CRAN. For instance, Twitter, Inc. provides AnomalyDetection package on GitHub, but they won’t submit to CRAN [3]. You can install such packages conveniently using devtools.


There is a difference between install.packages() and install_github() in their required argument. install.packages() takes package names, while install_github() needs repository names in addition. It means that when you want to install a package on GitHub, you must remember its repository name correctly.

The trouble is that the usernames of GitHub are often hard to remember. Developers consider their package names so that users can understand their functionalities intuitively. However, they often decide username incautiously. For instance, ggfortify is an excellent package on GitHub, but who created it? What is its username? The answer is sinhrks [4]. It seems to be difficult to remember it.

The githubinstall package provides a way to install packages on GitHub by only their package names just like install.packages().

 - twitter/AnomalyDetection  Anomaly Detection with R
Do you want to install the package (Y/n)?  

githubinstall() suggests GitHub repositories from input package names and asks whether you install it.

Furthermore, you may succeed in installing packages from a faint memory because our package automatically corrects its spelling by fuzzy string search.


2 Installation

You can install the githubinstall package from CRAN.


You can also install the package from GitHub.

install.packages("devtools") # if you have not installed "devtools" package

The source code for githubinstall package is available on GitHub at

3 Details

The githubinstall package provides several useful functions.

The functions have common prefix gh. githubinstall() is an alias of gh_install_packages().

To use these functions, first, you should load the package as follows.


3.1 Install Packages from GitHub

gh_install_packages() enables to install packages on GitHub by only package names.

 - twitter/AnomalyDetection  Anomaly Detection with R
Do you want to install the package (Y/n)?  

The function suggests GitHub repositories. If you type ‘Y’ or ‘y’ and press ‘Enter’ (the default is ‘Y’), then the installation of the package will begin. The suggestion is made by looking for a list of R packages on GitHub. Gepuro Task Views provides the list.

If it found multiple candidates, you can select one of them.

Select a number or, hit 0 to cancel. 

1: amurali2/cats      cats
2: danielwilhelm/cats No description or website provided.
3: hilaryparker/cats  An R package for cat-related functions #rcatladies
4: lolibear/cats      No description or website provided.
5: rafalszota/cats    No description or website provided.
6: tahir275/cats      ff


githubinstall() is an alias of gh_install_packages().


3.1.1 Specify Git References (Branch, Tag, Commit and Pull Request)

You can install packages by specifying Git references (branch, tag, commit and pull request).

Developers are divided in policy to manage R packages on GitHub. If a package is going to be developed in “develop” branch, you may want to install the package from the branch.

gh_install_packages() has ref argument to specify Git references. For instance, you can install awaptools from the “develop” branch as follows:

gh_install_packages("awaptools", ref = "develop")

You may sometimes encounter failing to install packages because its repository HEAD is not valid no longer. In such case, you can specify a tag or commit to ref. In most cases, developers add tags on an unbroken commit. For instance, you can install densratio from the “v0.0.3” tag as follows:

gh_install_packages("densratio", ref = "v0.0.3")

Even if you cannot find such tags, you can install packages from any commit that is valid. For instance, you can install densratio from the “e8233e6” commit as follows:

gh_install_packages("densratio", ref = "e8233e6")

Finally, you may find a patch for fixing bugs as a pull request. In such case, you can specify pull requests to ref using github_pull(). For instance, you can install dplyr from the pull request #2058 as follows:

gh_install_packages("dplyr", ref = github_pull("3274"))

3.2 Suggest Repositories

gh_install_packages() prompts you to install the suggested packages. But you may just want to know what will be suggestions.

gh_suggest() returns the suggested repository names as a vector.

#> [1] "twitter/AnomalyDetection"
#>  [1] "Kkm5/cats"             "amurali2/cats"        
#>  [3] "briglx/cats"           "danielwilhelm/cats"   
#>  [5] "davidluizrusso/cats"   "fadiphi/cats"         
#>  [7] "germayneng/cats"       "hilaryparker/cats"    
#>  [9] "jonathanelee1993/cats" "lloydlow/cats"        
#> [11] "lolibear/cats"         "mfabla/cats"          
#> [13] "nkatiyar/cats"         "oliviergimenez/cats"  
#> [15] "piyush-kgp/cats"       "rafalszota/cats"      
#> [17] "riteekteek/cats"       "sunstat/cats"         
#> [19] "tahir275/cats"         "thackl/cats"          
#> [21] "tomis9/cats"           "verreet/cats"

Also, gh_suggest_username() is useful when you want to know usernames from a faint memory.

#> [1] "hadley"
#> [1] "yihui"

3.3 List the Packages

gh_list_packages() returns a list of R package repositories on GitHub as data.frame.

For example, if you want to get the repositories that have been created by hadley, run the following.

hadleyverse <- gh_list_packages(username = "hadley")
#>   username package_name                                              title
#> 1   hadley RcppDateTime                                                   
#> 2   hadley           S3  Helpers for Programming with the S3 Object System
#> 3   hadley   assertthat                     User friendly assertions for R
#> 4   hadley    babynames An R package contain all baby names data from the 
#> 5   hadley        bench                            Bechmarking tools for R
#> 6   hadley    bigrquery          An interface to Google's bigquery from R.

By using the result, you can install all packages created by hadley.

repos <- with(hadleyverse, paste(username, package_name, sep="/"))
githubinstall(repos) # I have not tried it

3.4 Search Packages by a Keyword

gh_search_packages() returns a list of R package repositories on GitHub that their titles contain a given keyword.

For example, if you want to search packages that are relevant to lasso, run the following.

lasso_packages <- gh_search_packages("lasso")
#>              username package_name                                   title
#> 1              CY-dev    sparseSVM  Solution Paths of Sparse Linear Supp..
#> 2     ChingChuan-Chen         milr  multiple-instance logistic regressio..
#> 3              FrankD        fuser  Fused lasso for high-dimensional reg..
#> 4           ManuSetty        SeqGL  SeqGL is a group lasso based algorit..
#> 5 PNNL-Comp-Mass-Spec    glmnetGLR  The primary goal was to build a clas..
#> 6        PingYangChen         milr  multiple-instance logistic regressio..

3.5 Show the Source Code of Functions on GitHub

gh_show_source() looks for a source code on GitHub for a given function and tries to open the place on your Web browser.

gh_show_source("mutate", repo = "dplyr")

If you have loaded the package that the function belongs to, you can input it directly.


This function may do not work well with Safari.

3.6 Update the List of R Packages

The githubinstall package uses Gepuro Task Views for getting the list of R packages on GitHub. Gepuro Task Views is crawling the GitHub and updates information every day. The package downloads the list of R packages from Gepuro Task Views each time it was loaded. Thus, you can always use the newest list of packages on a new R session.

However, you may use an R session for a long time. In such case, gh_update_package_list() is useful.

gh_update_package_list() updates the downloaded list of the R packages explicitly.