<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/cran-packages-on-github-and-some-cran-description-observations/"></div></div><div><a data-url="http://www.r-bloggers.com/cran-packages-on-github-and-some-cran-description-observations/" data-counturl="http://www.r-bloggers.com/cran-packages-on-github-and-some-cran-description-observations/" data-count="horizontal" data-text="CRAN Packages on GitHub (and some CRAN DESCRIPTION observations)" 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://rud.is/b/2016/07/10/cran-packages-on-github-and-some-cran-description-observations/"> R – rud.is</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Just about a week ago <a target="_blank" href="http://twitter.com/thosjleeper">@thosjleeper</a> posited something on twitter w/r/t how many CRAN packages had associations with GitHub (i.e. how many used GitHub for development). The <code>DESCRIPTION</code> file (that comes with all R packages) has some fields that can house this information and most folks who do use GitHub for development of R seem to use the <code>URL</code> field to host the repository URL, which looks something like this:</p>
<p><code>URL: http://github.com/ropenscilabs/geoparser</code></p>
<p>(that’s from <a target="_blank" href="http://twitter.com/ma_salmon">@ma_salmon</a>’s ++good <code>geoparser</code> package)</p>
<p>There may be traces of GitHub URLs in other fields, but I took this initial naïve assumption and added a step to my daily home CRAN mirror scripts (what, you don’t have your own CRAN mirror at home, too?) to generate two files that you, the R community, can use whenever you want to inspect GitHub R packages:</p>
<ul>
<li><a target="_blank" href="http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.Rdata"><code>http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.Rdata</code></a> (R data file)</li>
<li><a target="_blank" href="http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.json"><code>http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.json</code></a> (json file)</li>
</ul>
<p>You can use:</p>
<p><code>load(url(&quot;http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.Rdata&quot;))</code></p>
<p>or</p>
<p><code>jsonlite::fromJSON(&quot;http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.json&quot;)</code> </p>
<p>to read these files but they change only daily, so you might want to <code>download.file()</code> them vs waste bandwidth re-reading them intra-day.</p>
<p>As of this post there were 1,544 packages meeting my naïve criteria. </p>
<p>One interesting side-discovery of this effort was to discover that there are 122 “distinct” <code>DESCRIPTION</code> fields in-use, but some of those are mixed-case versions of each other (118 total unique ones). Plus, there doesn’t seem to be as hard and fast a rule on the fields as one might think. Some examples:</p>
<ul>
<li><code>acknowledgement</code>, <code>acknowledgements</code>, <code>acknowledgments</code></li>
<li><code>bioviews</code>, <code>biocviews</code></li>
<li><code>keyword</code>, <code>keywords</code></li>
<li><code>reference</code>, <code>references</code>, <code>reference manual</code></li>
<li><code>systemrequirement</code>, <code>systemrequirements</code>, <code>systemrequirementsnote</code></li>
</ul>
<p>You can see the usage counts for all the fields in the table below:</p>
<p><center><br>
<iframe height="600" width="100%" src="http://rud.is/b/iframes/tabs/cranfields.html"></iframe><br>
</center> </p>
<p>But, I digress.</p>
<p>Who has the most CRAN packages with associated GitHub repositories? The code below <em>mostly</em> answers this. I say “mostly” since I don’t handle edge cases in the <code>URL</code> field (look at it to see what I mean). It’s also possible that there are traces of GitHub in other fields, and I’ll address those in my local CRAN parser at some point. Feel free to post your findings, fixes or enhancements in the comments.</p>
<pre><code>library(dplyr)
library(tidyr)
library(stringi)
library(DT)

download.file(&quot;http://public-r-data.s3-website-us-east-1.amazonaws.com/ghcran.Rdata&quot;,
              &quot;ghcran.Rdata&quot;)

load(&quot;ghcran.Rdata&quot;)

ghcran$URL %>% 
  stri_match_first_regex(&quot;://github.com/(.*?/[[:alnum:]_\\-\\.]+)&quot;) %>% 
  as.data.frame(stringsAsFactors=FALSE) %>% 
  setNames(c(&quot;url&quot;, &quot;repos&quot;)) %>% 
  filter(!is.na(repos)) %>% 
  separate(repos, c(&quot;author&quot;, &quot;repo&quot;), &quot;/&quot;, extra=&quot;drop&quot;) %>% 
  count(author) %>% 
  arrange(desc(n)) %>% 
  datatable()</code></pre>
<p><center><br>
<iframe height="600" width="100%" src="http://rud.is/b/iframes/tabs/ghcran.html"></iframe><br>
</center> </p>
<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/cran-packages-on-github-and-some-cran-description-observations/"></div></div><div><a data-url="http://www.r-bloggers.com/cran-packages-on-github-and-some-cran-description-observations/" data-counturl="http://www.r-bloggers.com/cran-packages-on-github-and-some-cran-description-observations/" data-count="vertical" data-text="CRAN Packages on GitHub (and some CRAN DESCRIPTION observations)" 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://rud.is/b/2016/07/10/cran-packages-on-github-and-some-cran-description-observations/"> R – rud.is</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/J8vbMfxfp90"></a></div>