<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/searching-for-r-packages/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rviews.rstudio.com/2018/10/22/searching-for-r-packages/"> R Views</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p> 

<br>
<br>
<br>
<br>
<br>
<br>
</p>
<hr>
<p>Searching for R packages is a vexing problem for both new and experienced R users. With over 13,000 packages already on <a rel="nofollow" href="https://cran.r-project.org/web/packages/" target="_blank">CRAN</a>, and new packages arriving at a rate of almost 200 per month, it is impossible to keep up. Package names can be almost anything, and they are rarely informative, so <a rel="nofollow" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_blank">searching by name</a> is of little help. I make it a point to look at all of the new packages arriving on CRAN each month, but after a month or so, when asked about packages related to some particular topic, more often than not, I have little more to offer than a vague memory that I saw something that might be useful.</p>
<p>Fortunately, package developers have provided some very useful tools, if you know where to look. <img alt="🙂" src="https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" class="wp-smiley"> This post presents a search strategy based on some relatively new packages I have come across in my monthly review.</p>
<pre><code>library(tidyverse)</code></pre>
<pre><code>## ── Attaching packages ───────────────────────────────────────────── tidyverse 1.2.1 ──</code></pre>
<pre><code>## ✔ ggplot2 2.2.1     ✔ purrr   0.2.4
## ✔ tibble  1.4.2     ✔ dplyr   0.7.5
## ✔ tidyr   0.8.1     ✔ stringr 1.3.1
## ✔ readr   1.1.1     ✔ forcats 0.3.0</code></pre>
<pre><code>## ── Conflicts ──────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()</code></pre>
<pre><code>library(packagefinder)
library(dlstats)
library(cranly)</code></pre>
<p><a rel="nofollow" href="https://cran.r-project.org/package=packagefinder" target="_blank">packagefinder v0.0.7</a>, which appeared on CRAN this past July, goes right to the heart of the problem and shows great promise. The function <code>findPackage()</code> allows you to do a keyword search through the metadata of all CRAN packages. Since I am researching a possible post on <a rel="nofollow" href="https://thomasleeper.com/Rcourse/Tutorials/permutationtests.html" target="_blank">Permutation Tests</a>, I thought I would give <code>packagefinder::findPackage()</code> the most straightforward search text I could think of. (Note that the link for <code>Permutation Tests</code> above goes to an example by Thomas Leeper that references the <code>coin</code> package. This is a pretty strong hint that I expect to find <code>coin</code> prominently listed among the results.)</p>
<p>Also note, that making the output a <code>tibble</code> is not just obsessive-compulsive tidy behavior. The default print method sends the output to the Viewer in the RStudio IDE.</p>
<pre><code>pt_pkg &lt;- as.tibble(findPackage(&quot;permutation test&quot;))</code></pre>
<pre><code>## 
##  59  out of  13256  CRAN packages found in 6 seconds.</code></pre>
<pre><code>pt_pkg</code></pre>
<pre><code>## # A tibble: 59 x 5
##    SCORE NAME       DESC_SHORT                          DOWNL_TOTAL  GO   
##    </code></pre>