<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/visualizing-package-performance-using-rperform-and-grammar-of-graphics/"></div></div><div><a data-url="http://www.r-bloggers.com/visualizing-package-performance-using-rperform-and-grammar-of-graphics/" data-counturl="http://www.r-bloggers.com/visualizing-package-performance-using-rperform-and-grammar-of-graphics/" data-count="horizontal" data-text="Visualizing package performance using Rperform and Grammar of Graphics" 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="https://techandmortals.wordpress.com/2016/06/28/visualizing-package-performance-using-rperform-and-grammar-of-graphics/"> R – Tech and Mortals</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<blockquote>
<p><strong>The greatest value of a picture is when it forces us to notice what we never expected to see.</strong><br>
―John Tukey</p>
</blockquote>
<p>Replace ‘picture’ in the above quote with ‘data visualization’ and it will still ring true; maybe even more so. To provide valuable insights to package developers is exactly what <a target="_blank" href="http://github.com/analyticalmonk/rperform/">Rperform</a> strives to do through it’s visualization functions.</p>
<h4>Background</h4>
<p>If you are new to Rperform, consider going through it’s <a target="_blank" href="https://github.com/analyticalmonk/rperform/#rperform">Github README</a> once.<br>
In a nutshell, Rperform is an R package that allows package developers to track and visualize quantitative performance metrics of their code, over time. <b>It focuses on providing changes in a package’s performance metrics, related to runtime and memory usage, over different git versions and across git branches.</b></p>
<h4>Visualizing package performance across two branches</h4>
<p>As discussed in a <a target="_blank" href="https://techandmortals.wordpress.com/2016/05/21/rperform-in-google-summer-of-code-2016/">previous blog post</a>, data visualizations, UI and Travis-CI integration are the focal points of this year’s <a target="_blank" href="http://summerofcode.withgoogle.com/">GSoC</a> for Rperform.</p>
<figure data-shortcode="caption" class="wp-caption"><img alt="gsoc2016" class="wp-image-426" src="http://i1.wp.com/techandmortals.files.wordpress.com/2016/05/gsoc2016.png?w=456&ssl=1" data-recalc-dims="1"><br>
<figcaption class="wp-caption-text">It’s that time of the year again!</figcaption>
</figure>
<p>One month into the GSoC period, most of the work that I have put in so far has been directed towards improving Rperform’s visualization capabilities. A developer can now compare and visualize performance of a package across two git branches.  This can be done using the <code>plot_branchmetrics()</code> function. Two key parameters which this function takes are <em>branch1</em> and <em>branch2</em>. It’s assumed that <em>branch1 (</em>this might be your development branch) is to be merged into <em>branch2</em> (this might be the master branch), or that<em> branch1 </em>originated from<em> branch2.</em> The relationship between such 2 branches is depicted visually in the below figure.</p>
<p><img alt="compare_branches" class="wp-image-57" src="http://i2.wp.com/techandmortals.files.wordpress.com/2015/06/compare_branches-2.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>
<p>Following is an example from the Rperform <a target="_blank" href="https://github.com/analyticalmonk/Rperform/wiki/Plotting-package-metrics-with-Rperform#examples-1">wiki</a> which depicts the usage of <code>plot_branchmetrics()</code> on the package, <a target="_blank" href="http://github.com/tdhock/stringr">stringr</a>:</p>
<p><code>## Warning: Always set the current directory to be the root directory of the package to be tested.
<p>Rperform::plot_branchmetrics(test_path = &quot;tests/testthat/test-interp.r&quot;, metric = &quot;memory&quot;, branch1 = &quot;rperform_test&quot;, branch2 = &quot;master&quot;, save_data = F, save_plots = F)</p>
<figure data-shortcode="caption" class="wp-caption"><img alt="stringr_plotbranchmem" class="wp-image-568" src="http://i2.wp.com/techandmortals.files.wordpress.com/2016/06/stringr_plotbranchmem.png?resize=456%2C420&ssl=1" data-recalc-dims="1"><br>
<figcaption class="wp-caption-text">Visualizing memory usage across git branches</figcaption>
</figure>
<p>The commit on the left-hand side (LHS) of the vertical line in the above plot is the latest commit from the branch provided as the parameter, <em>branch2</em>. The right-hand side (RHS) contains the commits from the branch provided as the parameter, <em>branch1</em>. The commits on the RHS run from <em>branch1</em>‘s latest commit until the first commit common to <em>branch2</em>.<br>
<strong>To know more about how to visualize your package’s performance, check out this <a target="_blank" href="https://github.com/analyticalmonk/Rperform/wiki/Plotting-package-metrics-with-Rperform">Github Wiki</a>.</strong></p>
<h4>Grammar of Graphics and Interactivity</h4>
<p><a target="_blank" href="http://www.springer.com/us/book/9780387245447">Grammar of Graphics</a> is a framework that coherently ties together many aspects of designing, implementing, reading, and understanding a graphic.<a target="_blank" href="http://civilstat.com/2012/09/the-grammar-of-graphics-notes-on-first-reading/">[1]</a> Created by Leland Wilkinson, it’s a systematic way of thinking about visualizations. <a target="_blank" href="http://github.com/hadley/ggplot2">ggplot2</a>, developed by Hadley Wickham, is more or less an implementation of Wilkinson’s GoG framework. ggplot2 allows one to create a visualization in a layer-by-layer manner by associating data variables to visual properties (or aesthetics). This approach allows one to create an <a target="_blank" href="http://www.r-graph-gallery.com/portfolio/ggplot2-package/">astounding variety of visualizations</a>. Rperform uses ggplot2 under-the-hood to create plots such as the one shown above.</p>
<p>When I had started thinking about implementing interactivity in Rperform’s plots, I wanted a solution without giving up ggplot2’s capabilities and the GoG philosophy. The <a target="_blank" href="http://github.com/tdhock/animint">animint</a> package, developed by Toby Dylan Hocking (one of my mentors), has proven to be a good fit since it works in tandem with ggplot2 to create interactive plots. This bit is still a work-in-progress but one can get a taste of how interactivity can be helpful through this <a target="_blank" href="https://analyticalmonk.github.io/Rperform-blog-gog/">example</a>. Here, clicking on a point takes you to the github page for the commit which the point represented.</p>
<p>I will be writing another post after finishing implementation of the functions returning interactive visualizations. That’s all for now, folks!</p>
<p><strong><span>Note</span>:<br>
If you are an R package developer, please <a target="_blank" href="http://github.com/analyticalmonk/rperform/">try out Rperform</a> on your code and provide feedback if possible. Drop me a <a target="_blank" href="mailto:akashtndn.acm@gmail.com">mail</a>, or hit me up on <a target="_blank" href="http://twitter.com/AkashTandon">Twitter</a>, <a target="_blank" href="http://github.com/analyticalmonk">Github</a> or <a target="_blank" href="https://www.quora.com/profile/Akash-Tandon-1">Quora</a>.</strong><br>
<strong>If any problem arises, please <a target="_blank" href="http://github.com/analyticalmonk/rperform/issues">open an issue</a> on Github.</strong></p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techandmortals.wordpress.com/465/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/techandmortals.wordpress.com/465/" border="0"></a> <img alt="" src="http://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></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/visualizing-package-performance-using-rperform-and-grammar-of-graphics/"></div></div><div><a data-url="http://www.r-bloggers.com/visualizing-package-performance-using-rperform-and-grammar-of-graphics/" data-counturl="http://www.r-bloggers.com/visualizing-package-performance-using-rperform-and-grammar-of-graphics/" data-count="vertical" data-text="Visualizing package performance using Rperform and Grammar of Graphics" 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="https://techandmortals.wordpress.com/2016/06/28/visualizing-package-performance-using-rperform-and-grammar-of-graphics/"> R – Tech and Mortals</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/1zlujZHUQe0"></a></div></code>