<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/"></div></div><div><a data-url="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/" data-counturl="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/" data-count="horizontal" data-text="githubinstall: New R Package for Easy to Install R Packages on GitHub" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://mockquant.blogspot.com/2016/06/githubinstall-new-r-package-for-easy-to.html"> HOXO-M - anonymous data analyst group in Japan - </a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<h2>1. Overview</h2>
<p>A growing number of R packages are created by various people in the world. A part of the cause of it is the <strong>devtools</strong> package that makes it easy to develop R packages <a target="_blank" href="https://www.rstudio.com/products/rpackages/devtools/">[1]</a>. The <strong>devtools</strong> package not only facilitates the process to develop R packages but also provides an another way to distribute R packages.</p>
<p>When developers publish R packages, the CRAN <a target="_blank" href="https://cran.r-project.org/">[2]</a> is commonly used. You can install the packages that are available on CRAN using <code>install.package()</code>. For example, you can install <strong>dplyr</strong> package as follows:</p>
<div>
<pre><code><span>install.packages</span>(<span>&quot;dplyr&quot;</span>)</code></pre>
</div>
<p>The <strong>devtools</strong> package provides <code>install_github()</code> that enables installing packages from GitHub.</p>
<div>
<pre><code><span>library</span>(devtools)<br><span>install_github</span>(<span>&quot;hadley/dplyr&quot;</span>)</code></pre>
</div>
<p>Therefore, developers can distribute R packages that is developing on GitHub. Moreover, there are some developers that they have no intention to submit to CRAN. For instance, Twitter, Inc. provides <strong>AnomalyDetection</strong> package on GitHub but it will not be available on CRAN <a target="_blank" href="https://blog.twitter.com/2015/introducing-practical-and-robust-anomaly-detection-in-a-time-series">[3]</a>. You can install such packages easily using <strong>devtools</strong>.</p>
<div>
<pre><code><span>library</span>(devtools)<br><span>install_github</span>(<span>&quot;twitter/AnomalyDetection&quot;</span>)</code></pre>
</div>
<p>There is a difference between <code>install.packages()</code> and <code>install_github()</code> in the required argument. <code>install.packages()</code> takes package names, while <code>install_github()</code> needs repository names. It means that when you want to install a package on GitHub you must remember its repository name correctly.</p>
<p>The trouble is that the usernames of GitHub are often hard to remember. Developers consider the package names so that users can understand the functionalities intuitively. However, they often decide username incautiously. For instance, <strong>ggfortify</strong> is a great package on GitHub, but who created it? What is the username? The answer is <em>sinhrks</em> <a target="_blank" href="https://github.com/sinhrks/ggfortify">[4]</a>. It seems to be difficult to remember it.</p>
<p>The <strong>githubinstall</strong> package provides a way to install packages on GitHub by only the package names just like <code>install.packages()</code>.</p>
<div>
<pre><code><span>library</span>(githubinstall)<br><span>githubinstall</span>(<span>&quot;AnomalyDetection&quot;</span>)</code></pre>
</div>
<pre><code>Suggetion:<br> - twitter/AnomalyDetection<br>Do you install the package? <br><br>1: Yes (Install)<br>2: No (Cancel)</code></pre>
<p><code>githubinstall()</code> suggests the GitHub repository from package names, and asks whether you want to execute the installation.</p>
<p>Furthermore, you may succeed in installing packages from a faint memory because our package automatically correct its spelling by fuzzy string search.</p>
<div>
<pre><code><span>githubinstall</span>(<span>&quot;AnomaryDetection&quot;</span>)<br><span>githubinstall</span>(<span>&quot;AnomalyDetect&quot;</span>)<br><span>githubinstall</span>(<span>&quot;anomaly-detection&quot;</span>)</code></pre>
</div>
</div>
<div>
<h2>2. Installation</h2>
<p>You can install the <strong>githubinstall</strong> package from CRAN.</p>
<div>
<pre><code><span>install.packages</span>(<span>&quot;githubinstall&quot;</span>)</code></pre>
</div>
<p>The source code for <strong>githubinstall</strong> package is available on GitHub at</p>
<ul>
<li><a target="_blank" href="https://github.com/hoxo-m/githubinstall">https://github.com/hoxo-m/githubinstall</a>.</li>
</ul>
</div>
<div>
<h2>3. Details</h2>
<p>The <strong>githubinstall</strong> package provides several useful functions.</p>
<ul>
<li><code>githubinstall()</code> or <code>gh_install_packages()</code></li>
<li><code>gh_suggest()</code></li>
<li><code>gh_suggest_username()</code></li>
<li><code>gh_list_packages()</code></li>
<li><code>gh_search_packages()</code></li>
<li><code>gh_show_source()</code></li>
<li><code>gh_update_package_list()</code></li>
</ul>
<p>The functions have common prefix <code>gh</code>. <code>githubinstall()</code> is an alias of <code>gh_install_packages()</code>.</p>
<p>To use these functions, first, you should load the package as follows.</p>
<div>
<pre><code><span>library</span>(githubinstall)</code></pre>
</div>
<div>
<h3>3.1. Install Packages from GitHub</h3>
<p><code>githubinstall()</code> enables to install packages on GitHub by only package names.</p>
<div>
<pre><code><span>githubinstall</span>(<span>&quot;AnomalyDetection&quot;</span>)</code></pre>
</div>
<pre><code>Suggestion:<br> - twitter/AnomalyDetection<br>Do you install the package? <br><br>1: Yes (Install)<br>2: No (Cancel)<br><br>Selection: </code></pre>
<p>The function suggests GitHub repositories. If you type ‘1’ and ‘enter’, then installation of the package will begin. The suggestion is made of looking for the list of R packages on GitHub. The list is provided by <a target="_blank" href="http://rpkg.gepuro.net/">Gepuro Task Views</a>.</p>
<p>If multiple candidates are found, you can select one of them.</p>
<div>
<pre><code><span>githubinstall</span>(<span>&quot;cats&quot;</span>)</code></pre>
</div>
<pre><code>Select one repository or, hit 0 to cancel. <br><br>1: amurali2/cats      cats<br>2: danielwilhelm/cats No description or website provided.<br>3: hilaryparker/cats  An R package for cat-related functions #rcatladies<br>4: lolibear/cats      No description or website provided.<br>5: rafalszota/cats    No description or website provided.<br>6: tahir275/cats      ff<br><br>Selection: </code></pre>
<p><code>githubinstall()</code> is an alias of <code>gh_install_packages()</code>.</p>
<div>
<pre><code><span>gh_install_packages</span>(<span>&quot;AnomalyDetection&quot;</span>)</code></pre>
</div>
</div>
<div>
<h3>3.2. Suggest Repositories</h3>
<p><code>githubinstall()</code> prompts you to install the suggested packages. But you may just want to know what will be suggestions.</p>
<p><code>gh_suggest()</code> returns the suggested repository names as a vector.</p>
<div>
<pre><code><span>gh_suggest</span>(<span>&quot;AnomalyDetection&quot;</span>)</code></pre>
</div>
<pre><code>## [1] &quot;twitter/AnomalyDetection&quot;</code></pre>
<div>
<pre><code><span>gh_suggest</span>(<span>&quot;cats&quot;</span>)</code></pre>
</div>
<pre><code>## [1] &quot;amurali2/cats&quot;       &quot;danielwilhelm/cats&quot;  &quot;davidluizrusso/cats&quot;<br>## [4] &quot;hilaryparker/cats&quot;   &quot;lolibear/cats&quot;       &quot;rafalszota/cats&quot;    <br>## [7] &quot;tahir275/cats&quot;</code></pre>
<p>In addition, <code>gh_suggest_username()</code> is useful if you want to know usernames from a faint memory.</p>
<div>
<pre><code><span>gh_suggest_username</span>(<span>&quot;hadly&quot;</span>)</code></pre>
</div>
<pre><code>## [1] &quot;hadley&quot;</code></pre>
<div>
<pre><code><span>gh_suggest_username</span>(<span>&quot;yuhui&quot;</span>)</code></pre>
</div>
<pre><code>## [1] &quot;yihui&quot;</code></pre>
</div>
<div>
<h3>3.3. List the Packages</h3>
<p><code>gh_list_packages()</code> returns the list of R package repositories on GitHub as <code>data.frame</code>.</p>
<p>For example, if you want to get the repositories that have been created by <em>hadley</em>, run the following.</p>
<div>
<pre><code>hadleyverse &lt;-<span> </span><span>gh_list_packages</span>(<span>username =</span> <span>&quot;hadley&quot;</span>)<br><span>head</span>(hadleyverse)</code></pre>
</div>
<pre><code>##   username package_name                                              title<br>## 1   hadley   assertthat                     User friendly assertions for R<br>## 2   hadley    babynames An R package contain all baby names data from the <br>## 3   hadley    bigrquery          An interface to Google's bigquery from R.<br>## 4   hadley     bookdown                                              Watch<br>## 5   hadley   clusterfly An R package for visualising high-dimensional clus<br>## 6   hadley      decumar                           An alternative to sweave</code></pre>
<p>By using the result, you can install all packages created by hadley.</p>
<div>
<pre><code>repos &lt;-<span> </span><span>with</span>(hadleyverse, <span>paste</span>(username, package_name, <span>sep=</span><span>&quot;/&quot;</span>))<br><span>githubinstall</span>(repos) <span># I have not tried it</span></code></pre>
</div>
</div>
<div>
<h3>3.4. Search Packages by a Keyword</h3>
<p><code>gh_search_packages()</code> returns the list of R package repositories on GitHub that the titles contains a given keyword.</p>
<p>For example, if you want to search packages that are relevant to <em>lasso</em>, run the following.</p>
<div>
<pre><code><span>gh_search_packages</span>(<span>&quot;lasso&quot;</span>)</code></pre>
</div>
<pre><code>##           username     package_name                                  title<br>## 1  ChingChuan-Chen             milr  multiple-instance logistic regressi..<br>## 2       YaohuiZeng         biglasso  Big Lasso: Extending Lasso Model Fi..<br>## 3      huayingfang          CCLasso  CCLasso: Correlation Inference for ..<br>## 4         mlampros FeatureSelection  Feature Selection in R using glmnet..<br>## 5             pnnl        glmnetLRC  Lasso and Elastic-Net Logistic Regr..<br>## 6       statsmaths         genlasso  Path algorithm for generalized lass..<br>## 7       vincent-dk         logitsgl  Fit Logistic Regression with Multi-..<br>## 8       vincent-dk             lsgl  Linear Multiple Output Using Sparse..<br>## 9       vincent-dk             msgl  High Dimensional Multiclass Classif..<br>## 10      vstanislas             GGEE  R Package for the Group Lasso Gene-..<br>## 11          zdk123       BatchStARS  R package for Stability Approach to..<br>## 12          zdk123           pulsar  R package for Stability Approach to..</code></pre>
</div>
<div>
<h3>3.5. Show the Source Code of Functions on GitHub</h3>
<p><code>gh_show_source()</code> looks for the source code of a given function on GitHub, and tries to open the place on Web browser.</p>
<div>
<pre><code><span>gh_show_source</span>(<span>&quot;mutate&quot;</span>, <span>&quot;dplyr&quot;</span>)</code></pre>
</div>
<p>If you have loaded the package that the function belongs to, you can input the function directly.</p>
<div>
<pre><code><span>library</span>(dplyr)<br><span>gh_show_source</span>(mutate)</code></pre>
</div>
<p>This function may do not work well with Safari.</p>
</div>
<div>
<h3>3.6. Update the List of R Packages</h3>
<p>The <strong>githubinstall</strong> package uses <a target="_blank" href="http://rpkg.gepuro.net/">Gepuro Task Views</a> 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.</p>
<p>However, you may use an R session for a long time. In such case, <code>gh_update_package_list()</code> is useful.</p>
<p><code>gh_update_package_list()</code> updates the downloaded list of the R packages explicitly.</p>
<div>
<pre><code><span>gh_update_package_list</span>()</code></pre>
</div>
</div>
</div>
<div>
<h2>4. Related Work</h2>
<ul>
<li>devtools: <a target="_blank" href="https://github.com/hadley/devtools">Tools to make an R developer’s life easier</a></li>
<li>ghit: <a target="_blank" href="https://github.com/cloudyr/ghit">Lightweight GitHub Package Installer</a></li>
<li>drat: <a target="_blank" href="https://github.com/eddelbuettel/drat">Drat R Archive Template</a></li>
<li>pacman: <a target="_blank" href="https://github.com/trinker/pacman">A package management tools for R</a></li>
<li>remotes: <a target="_blank" href="https://github.com/MangoTheCat/remotes">Install R packages from GitHub, Bitbucket, git, svn repositories, URLs</a></li>
</ul>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/"></div></div><div><a data-url="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/" data-counturl="http://www.r-bloggers.com/githubinstall-new-r-package-for-easy-to-install-r-packages-on-github/" data-count="vertical" data-text="githubinstall: New R Package for Easy to Install R Packages on GitHub" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://mockquant.blogspot.com/2016/06/githubinstall-new-r-package-for-easy-to.html"> HOXO-M - anonymous data analyst group in Japan - </a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/7XgPJvgmVrk"></a></div>