<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/r-packaging-industry-close-up-how-fast-are-we-growing/"></div></div><div><a data-url="http://www.r-bloggers.com/r-packaging-industry-close-up-how-fast-are-we-growing/" data-counturl="http://www.r-bloggers.com/r-packaging-industry-close-up-how-fast-are-we-growing/" data-count="horizontal" data-text="R packaging industry close-up: How fast are we growing?" 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://danielmarcelino.github.io/blog/2016/how-fast-are-we-growing.html"> Daniel's Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I worked a bit over the weekend preparing my talk to be delivered at the seminar organized by <a target="_blank" href="http://www.ibpad.com.br/">IBPAD</a> this week at University of Brasilia, addressing the interfaces of Big Data and Society.<br>
I was invited to present the R package SciencesPo for an eclectic crowd. Eclectic in terms of background as well as familiarity with R, so, I thought it would be a fair introduction to call the audience’s attention to the R ecosystem, particularly, the growing number of specialized packages made available through CRAN.</p>
<p>I gathered some log data from package downloads to produce the following figure. The main plot shows the number of published packages since 2005 (that are still available). Notice that the y-axis is in log scale. The small multiples inside also shows the count of packages published on CRAN, but only for packages submitted after 2013-01-01. It’s an arbitrary date that makes my job of estimating a growth rate of package submission a lot easier. The red line represents the modeled growth rate estimated for the period with an approximation of 5.6%/month.</p>
<p><img alt="center" src="http://i1.wp.com/danielmarcelino.github.io/img/2016/R-packages-growth-rate.png?w=456" data-recalc-dims="1"></p>
<h5>Needed packages</h5>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>ggplot2</span><span>)</span>
<span>library</span><span>(</span><span>grid</span><span>)</span>
<span>library</span><span>(</span><span>rvest</span><span>)</span>
<span>library</span><span>(</span><span>dplyr</span><span>)</span>
<span>library</span><span>(</span><span>zoo</span><span>)</span>
<span>library</span><span>(</span><span>SciencesPo</span><span>)</span></code></pre>
</figure>
<h5>Data manipulation</h5>
<figure>
<pre><code data-lang="r"><span>url</span> <span>&lt;-</span> <span>&quot;https://cran.r-project.org/web/packages/available_packages_by_date.html&quot;</span>

<span>page</span> <span>&lt;-</span> <span>read_html</span><span>(</span><span>url</span><span>)</span>
<span>page</span> <span>%>%</span>
<span>html_node</span><span>(</span><span>&quot;table&quot;</span><span>)</span> <span>%>%</span>
<span>html_table</span><span>()</span> <span>%>%</span>
<span>mutate</span><span>(</span><span>count</span> <span>=</span> <span>rev</span><span>(</span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>.</span><span>)))</span> <span>%>%</span>
<span>mutate</span><span>(</span><span>Date</span> <span>=</span> <span>as.Date</span><span>(</span><span>Date</span><span>))</span> <span>%>%</span>
<span>mutate</span><span>(</span><span>Month</span> <span>=</span> <span>format</span><span>(</span><span>Date</span><span>,</span> <span>format</span> <span>=</span> <span>&quot;%Y-%m&quot;</span><span>))</span> <span>%>%</span>
<span>group_by</span><span>(</span><span>Month</span><span>)</span> <span>%>%</span>
<span>summarise</span><span>(</span><span>published</span> <span>=</span> <span>min</span><span>(</span><span>count</span><span>))</span> <span>%>%</span>
<span>mutate</span><span>(</span><span>Date</span> <span>=</span> <span>as.Date</span><span>(</span><span>as.yearmon</span><span>(</span><span>Month</span><span>)))</span> <span>-></span> <span>pkgs</span></code></pre>
</figure>
<h5>The main plot</h5>
<figure>
<pre><code data-lang="r"><span>gg</span> <span>&lt;-</span> <span>ggplot</span><span>(</span><span>pkgs</span><span>,</span> <span>aes</span><span>(</span><span>x</span> <span>=</span> <span>Date</span><span>,</span> <span>y</span> <span>=</span> <span>published</span><span>))</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>geom_line</span><span>(</span><span>size</span> <span>=</span> <span>1.5</span><span>)</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>scale_y_log10</span><span>(</span> <span>breaks</span> <span>=</span> <span>c</span><span>(</span><span>0</span><span>,</span> <span>10</span><span>,</span> <span>100</span><span>,</span> <span>1000</span><span>,</span> <span>10000</span><span>),</span>
<span>labels</span> <span>=</span> <span>c</span><span>(</span><span>&quot;1&quot;</span><span>,</span> <span>&quot;10&quot;</span><span>,</span> <span>&quot;100&quot;</span><span>,</span> <span>&quot;1.000&quot;</span><span>,</span> <span>&quot;10.000&quot;</span><span>))</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>labs</span><span>(</span><span>x</span> <span>=</span> <span>&quot;&quot;</span><span>,</span> <span>y</span> <span>=</span> <span>&quot;# Packages (log)&quot;</span><span>,</span> <span>title</span> <span>=</span> <span>&quot;Packages published on CRAN ever since&quot;</span><span>)</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>theme_538</span><span>(</span><span>base_size</span> <span>=</span> <span>14</span><span>,</span> <span>base_family</span> <span>=</span> <span>&quot;Tahoma&quot;</span><span>)</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>theme</span><span>(</span><span>panel.grid.major.x</span> <span>=</span> <span>element_blank</span><span>())</span>
<span>gg</span> <span>&lt;-</span> <span>gg</span> <span>+</span> <span>geom_hline</span><span>(</span><span>yintercept</span> <span>=</span> <span>0</span><span>,</span>
<span>size</span> <span>=</span> <span>1</span><span>,</span> <span>colour</span> <span>=</span> <span>&quot;#535353&quot;</span><span>)</span>
<span>gg</span></code></pre>
</figure>
<figure>
<pre><code data-lang="r"><span>pkgs</span> <span>%>%</span>
  <span>filter</span><span>(</span><span>Date</span> <span>></span> <span>as.Date</span><span>(</span><span>&quot;2012-12-31&quot;</span><span>))</span> <span>%>%</span>
  <span>mutate</span><span>(</span><span>publishedGrowth</span> <span>=</span> <span>c</span><span>(</span><span>tail</span><span>(</span><span>.</span><span>$</span><span>published</span><span>,</span><span>-1</span><span>),</span> <span>NA</span><span>)</span> <span>/</span> <span>published</span><span>)</span> <span>%>%</span>
  <span>mutate</span><span>(</span><span>counter</span> <span>=</span> <span>1</span><span>:</span><span>nrow</span><span>(</span><span>.</span><span>))</span> <span>-></span> <span>new_pkgs</span></code></pre>
</figure>
<h5>The small multiples plot</h5>
<figure>
<pre><code data-lang="r"><span>gg2</span> <span>&lt;-</span> <span>ggplot</span><span>(</span><span>new_pkgs</span><span>,</span> <span>aes</span><span>(</span><span>x</span> <span>=</span> <span>Date</span><span>,</span> <span>y</span> <span>=</span> <span>published</span><span>))</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>geom_line</span><span>(</span><span>size</span> <span>=</span> <span>1</span><span>)</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>geom_line</span><span>(</span><span>data</span> <span>=</span> <span>new_pkgs</span><span>,</span> <span>aes</span><span>(</span><span>y</span> <span>=</span> <span>(</span><span>min</span><span>(</span><span>published</span><span>)</span> <span>*</span> <span>1.056</span> <span>^</span> <span>counter</span><span>)),</span>
<span>color</span> <span>=</span> <span>'red'</span><span>,</span><span>size</span> <span>=</span> <span>.7</span><span>,</span> <span>linetype</span> <span>=</span> <span>1</span><span>)</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>annotate</span><span>(</span><span>&quot;segment&quot;</span><span>,</span> <span>x</span> <span>=</span> <span>as.Date</span><span>(</span><span>&quot;2014-08-01&quot;</span><span>),</span> <span>xend</span> <span>=</span> <span>as.Date</span><span>(</span><span>&quot;2014-11-01&quot;</span><span>),</span> <span>y</span> <span>=</span> <span>500</span><span>,</span> <span>yend</span> <span>=</span> <span>500</span><span>,</span> <span>colour</span> <span>=</span> <span>&quot;red&quot;</span><span>,</span> <span>size</span> <span>=</span> <span>1</span><span>)</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>annotate</span><span>(</span><span>&quot;text&quot;</span><span>,</span> <span>x</span> <span>=</span> <span>as.Date</span><span>(</span><span>&quot;2015-10-01&quot;</span><span>),</span> <span>y</span> <span>=</span> <span>500</span><span>,</span> <span>label</span> <span>=</span> <span>&quot;5.6% growth estimation&quot;</span><span>,</span> <span>size</span> <span>=</span> <span>3.5</span><span>)</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>scale_y_continuous</span><span>()</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>labs</span><span>(</span><span>y</span> <span>=</span> <span>&quot;# Packages&quot;</span><span>,</span> <span>x</span> <span>=</span> <span>&quot;&quot;</span><span>,</span> <span>title</span> <span>=</span> <span>&quot;Packages published on CRAN since 2013&quot;</span><span>)</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>theme_538</span><span>(</span><span>legend</span> <span>=</span> <span>&quot;top&quot;</span><span>,</span> <span>base_size</span> <span>=</span> <span>11</span><span>,</span> <span>base_family</span> <span>=</span> <span>&quot;Tahoma&quot;</span><span>,</span> <span>colors</span> <span>=</span> <span>c</span><span>(</span><span>&quot;gray97&quot;</span><span>,</span>  <span>&quot;#D2D2D2&quot;</span><span>,</span>  <span>&quot;#2b2b2b&quot;</span><span>,</span> <span>&quot;#2b2b2b&quot;</span><span>))</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>theme</span><span>(</span><span>panel.grid.major.x</span> <span>=</span> <span>element_blank</span><span>())</span>
<span>gg2</span> <span>&lt;-</span> <span>gg2</span> <span>+</span> <span>geom_hline</span><span>(</span><span>yintercept</span> <span>=</span> <span>0</span><span>,</span> <span>size</span> <span>=</span> <span>.6</span><span>,</span> <span>colour</span> <span>=</span> <span>&quot;#535353&quot;</span><span>)</span>
<span>gg2</span>

<span>gg</span>
<span>print</span><span>(</span><span>gg2</span><span>,</span> <span>vp</span><span>=</span><span>viewport</span><span>(</span><span>.775</span><span>,</span> <span>.31</span><span>,</span> <span>.43</span><span>,</span> <span>.43</span><span>))</span></code></pre>
</figure>
<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/r-packaging-industry-close-up-how-fast-are-we-growing/"></div></div><div><a data-url="http://www.r-bloggers.com/r-packaging-industry-close-up-how-fast-are-we-growing/" data-counturl="http://www.r-bloggers.com/r-packaging-industry-close-up-how-fast-are-we-growing/" data-count="vertical" data-text="R packaging industry close-up: How fast are we growing?" 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://danielmarcelino.github.io/blog/2016/how-fast-are-we-growing.html"> Daniel's Blog</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/gpKC7Fepb8E"></a></div>