<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/rrrrs-in-r-letter-frequency-in-r-package-names/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.yihanwu.ca/post/rrrrs-in-r-letter-frequency-in-r-package-names/"> R on YIHAN WU</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>R package authors sometimes like to add the letter “r” to package names (for example, <a rel="nofollow" href="https://www.tidyverse.org/" target="_blank">the tidyverse packages</a>). <a rel="nofollow" href="https://www.yihanwu.ca/project/baRcodeR-package" target="_blank">baRcodeR</a> also has an extra “r” at the end as well. I thought I could use some available data see if the letter frequency changes compared to the English language average.</p>
<p></p>
<p>I used two data sets. The first is the percentage frequency of letters in the English language taken from this <a rel="nofollow" href="http://pi.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html" target="_blank">table of English letter frequencies</a> at the Cornell Math Explorers Club. I originally used the first table from [this wikipedia page] (<a rel="nofollow" href="https://en.wikipedia.org/wiki/Letter_frequency" target="_blank">https://en.wikipedia.org/wiki/Letter_frequency</a>) except that the percentages seem to sum to 108. A text file of the table is available <a rel="nofollow" href="https://www.yihanwu.ca/static/files/mec_letter_frequency.txt" target="_blank">here</a>.</p>
<p>The second dataset is a file of R package names. While it is possible to query CRAN to get the information, <a rel="nofollow" href="https://gist.github.com/daroczig" target="_blank">Gergely Daróczi</a> has already done so. The csv file can be download <a rel="nofollow" href="https://gist.githubusercontent.com/daroczig/3cf06d6db4be2bbe3368/raw/d16b3da080c149c88b5fd9722d3c3c02e4c8644d/results.csv" target="_blank">here</a>.</p>
<pre><code>avg_distribution &lt;- read.delim(&quot;../../static/files/mec_letter_frequency.txt&quot;, stringsAsFactors = F)
rpackage_info &lt;- read.csv(&quot;../../static/files/results.csv&quot;, stringsAsFactors = F)</code></pre>
<pre><code>avg_distribution &lt;- read.delim(&quot;mec_letter_frequency.txt&quot;, stringsAsFactors = F)
rpackage_info &lt;- read.csv(&quot;results.csv&quot;, stringsAsFactors = F)</code></pre>
<p>The <code>avg_distribution</code> table contains the count and frequency (in percentage) of each letter in descending order.</p>
<pre><code>names(avg_distribution) &lt;- c(&quot;Letter&quot;, &quot;avg_count&quot;, &quot;avg_frequency&quot;)</code></pre>
<p>The <code>rpackage_info</code> data frame contains a great deal of useful information including the date of first release and the number of version.</p>
<pre><code>head(rpackage_info)</code></pre>
<pre><code>##         name       first_release versions archived index
## 1         BN                </code></pre>