<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/the-plots-thicken/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://thinkr.biz/2018/02/07/plots-thicken/"> R – thinkr</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Every story needs a good plot</h2>
<p>One could think of data science as “art, grounded in facts”. It tells a story through visualisation. Both story and visualisation rely on a good plot. And an abundance of those has evolved over time. Many have their own dedicated Wikipedia page!</p>
<p>Which generate the most interest? How is the interest in each trending over time? Try this app to find out.<span></span></p>
<p><span>The app may take a moment to load:</span></p>
<p><br>
<iframe src="https://thinkr-biz.shinyapps.io/Plot_plotter/" width="100%" height="1130"></iframe></p>
<p><a rel="nofollow" href="https://thinkr-biz.shinyapps.io/Plot_plotter/" target="_blank">View full-width here</a>.</p>
<p>Note the utility of selecting the right scaling. The combination of “fixed” and “normal” reveals what must have been “world histogram day” on July 27th 2015, but little else.</p>
<h2>The need for speed</h2>
<p>Turning non-interactive code into an app sharpens the mind’s focus on performance. And <em>profvis,</em> integrated into RStudio via the <em>profile</em> menu option, is a wonderful “tool for helping you understand how R spends its time”.</p>
<p>My first version of the app was finger-tappingly slow.</p>
<p><em>Profvis</em> revealed the main culprit to be the pre-loading of a dataframe with the page-view data for <em>all</em> chart types (there are more than 100). Profiling prompted the more efficient “reactive” approach of loading the data <em>only</em> for the user’s selection (maximum of 8).</p>
<p>Profiling also showed that rounding the corners of the <em>plot.background</em> with additional grid-package code was expensive. App efficiency felt more important than minor cosmetic detailing. And most users would probably barely notice (had I not drawn attention to it here).</p>
<h2>R toolkit</h2>
<div>
<table>
<thead>
<tr>
<th> </th>
<th><strong>Packages</strong></th>
<th><strong>Functions</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2"><img src="https://i1.wp.com/thinkr.biz/wp-content/uploads/2017/10/Program-e1509478672361.png?resize=100%2C100&ssl=1" alt="" width="100" class="wp-image-135" data-recalc-dims="1" height="100"></td>
<td>purrr</td>
<td>map_df</td>
</tr>
<tr>
<td>profvis</td>
<td>profvis</td>
</tr>
<tr>
<td rowspan="2"><img src="https://i0.wp.com/thinkr.biz/wp-content/uploads/2017/10/Import-e1509478685299.png?resize=100%2C100&ssl=1" alt="" width="100" class="wp-image-134" data-recalc-dims="1" height="100"></td>
<td>pageviews</td>
<td>article_pageviews</td>
</tr>
<tr>
<td>rvest</td>
<td>read_html; html_nodes; html_text</td>
</tr>
<tr>
<td rowspan="4"><img src="https://i2.wp.com/thinkr.biz/wp-content/uploads/2017/10/Transform-e1509478657749.png?resize=100%2C100&ssl=1" alt="" width="100" class="wp-image-136" data-recalc-dims="1" height="100"></td>
<td>dplyr</td>
<td>mutate; select; </td>
</tr>
<tr>
<td>stringr</td>
<td>str_replace_all</td>
</tr>
<tr>
<td>lubridate</td>
<td>ymd</td>
</tr>
<tr>
<td>tibble</td>
<td>data_frame</td>
</tr>
<tr>
<td rowspan="4"><img src="https://i1.wp.com/thinkr.biz/wp-content/uploads/2017/10/Visualize-e1509478640644.png?resize=100%2C100&ssl=1" alt="" width="100" class="wp-image-137" data-recalc-dims="1" height="100"></td>
<td>ggplot2</td>
<td>geom_line; geom_smooth; facet_wrap</td>
</tr>
<tr>
<td>ggthemes</td>
<td>theme_economist; economist_pal</td>
</tr>
<tr>
<td>shiny</td>
<td>fluidPage; reactive; renderPlot; shinyApp; selectInput; wellPanel; helpText; selectizeInput; titlePanel; mainPanel; plotOutput</td>
</tr>
<tr>
<td>shinythemes</td>
<td>shinytheme</td>
</tr>
</tbody>
</table>
</div>
<p></p>
<p><a rel="nofollow" href="https://thinkr.biz/wp-content/uploads/2018/02/app.html" target="_blank">View the code here</a>.</p>
<h3>Citations / Attributions</h3>
<p>R Development Core Team (2008). R: A language and environment for<br>
statistical computing. R Foundation for Statistical Computing,<br>
Vienna, Austria. ISBN 3-900051-07-0, URL <a rel="nofollow" href="http://www.r-project.org/" target="_blank">http://www.R-project.org</a>.</p>
<p> </p>
<p>The post <a rel="nofollow" href="https://thinkr.biz/2018/02/07/plots-thicken/" target="_blank">The plots thicken</a> appeared first on <a rel="nofollow" href="https://thinkr.biz/" target="_blank">thinkr</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://thinkr.biz/2018/02/07/plots-thicken/"> R – thinkr</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/ZmwDOmrbGk8" height="1"></a></div>