<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/analyzing-metadata-for-cran-packages/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rviews.rstudio.com/2018/03/08/cran-package-metadata/"> R Views</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I have been searching for various ways to find information about R packages for some time now, but I only recently learned about the <code>CRAN_package_db()</code> function in the base <code>tools</code> package. If a colleague hadn’t pointed it out to me, I am sure I would never have found it on my own.</p>
<pre><code>pdb &lt;- tools:::CRAN_package_db() </code></pre>
<p>When invoked, this function goes out to the CRAN mirror specified by the environment variable <code>R_CRAN_WEB</code> and returns a data frame containing a whole lot of information about each package currently on CRAN. It is a treasure trove of meta data.</p>
<pre><code>load(file=&quot;../../static/post/2018-02-26-Rickert-CRAN-metadata_files/pdbJan31.RDA&quot;)
class(pdb)</code></pre>
<pre><code>## [1] &quot;data.frame&quot;</code></pre>
<pre><code>dim(pdb)</code></pre>
<pre><code>## [1] 12123    65</code></pre>
<pre><code>names(pdb)</code></pre>
<pre><code>##  [1] &quot;Package&quot;                 &quot;Version&quot;                
##  [3] &quot;Priority&quot;                &quot;Depends&quot;                
##  [5] &quot;Imports&quot;                 &quot;LinkingTo&quot;              
##  [7] &quot;Suggests&quot;                &quot;Enhances&quot;               
##  [9] &quot;License&quot;                 &quot;License_is_FOSS&quot;        
## [11] &quot;License_restricts_use&quot;   &quot;OS_type&quot;                
## [13] &quot;Archs&quot;                   &quot;MD5sum&quot;                 
## [15] &quot;NeedsCompilation&quot;        &quot;Additional_repositories&quot;
## [17] &quot;Author&quot;                  &quot;Authors@R&quot;              
## [19] &quot;Biarch&quot;                  &quot;BugReports&quot;             
## [21] &quot;BuildKeepEmpty&quot;          &quot;BuildManual&quot;            
## [23] &quot;BuildResaveData&quot;         &quot;BuildVignettes&quot;         
## [25] &quot;Built&quot;                   &quot;ByteCompile&quot;            
## [27] &quot;Classification/ACM&quot;      &quot;Classification/ACM-2012&quot;
## [29] &quot;Classification/JEL&quot;      &quot;Classification/MSC&quot;     
## [31] &quot;Classification/MSC-2010&quot; &quot;Collate&quot;                
## [33] &quot;Collate.unix&quot;            &quot;Collate.windows&quot;        
## [35] &quot;Contact&quot;                 &quot;Copyright&quot;              
## [37] &quot;Date&quot;                    &quot;Description&quot;            
## [39] &quot;Encoding&quot;                &quot;KeepSource&quot;             
## [41] &quot;Language&quot;                &quot;LazyData&quot;               
## [43] &quot;LazyDataCompression&quot;     &quot;LazyLoad&quot;               
## [45] &quot;MailingList&quot;             &quot;Maintainer&quot;             
## [47] &quot;Note&quot;                    &quot;Packaged&quot;               
## [49] &quot;RdMacros&quot;                &quot;SysDataCompression&quot;     
## [51] &quot;SystemRequirements&quot;      &quot;Title&quot;                  
## [53] &quot;Type&quot;                    &quot;URL&quot;                    
## [55] &quot;VignetteBuilder&quot;         &quot;ZipData&quot;                
## [57] &quot;Published&quot;               &quot;Path&quot;                   
## [59] &quot;X-CRAN-Comment&quot;          &quot;Reverse depends&quot;        
## [61] &quot;Reverse imports&quot;         &quot;Reverse linking to&quot;     
## [63] &quot;Reverse suggests&quot;        &quot;Reverse enhances&quot;       
## [65] &quot;MD5sum&quot;</code></pre>
<p>Working with the information returned may require a bit of data wrangling. In this post, I’ll show a cleaned-up (but far from elegant) version of some of the work I did to prepare for my rstudio::conf 2018 talk, <a rel="nofollow" href="https://www.rstudio.com/resources/videos/what-makes-a-great-r-package/" target="_blank">What Makes a Great R Package?</a>, as an example of working with the character data. I was interested in getting a sense of the collaboration that goes into writing a typical R package, along with a feel for how useful a package may be for other package developers. The proxy I chose for collaboration is the number of authors listed for each package. My proxy for usefulness to other package developers was the union of reverse depends and reverse imports.</p>
<p>The first thing I did was select a subset of the data frame to work on.</p>
<pre><code>meta_data &lt;- pdb[, c(1,4,5,17,60,61)]
names(meta_data) &lt;- c(&quot;Package&quot;,&quot;Dep&quot;,&quot;Imp&quot;,&quot;Aut&quot;,&quot;RD&quot;,&quot;RI&quot;)
glimpse(meta_data)</code></pre>
<pre><code>## Observations: 12,123
## Variables: 6
## $ Package </code></pre>