<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/some-tools-for-writing-shiny-apps/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://feedproxy.google.com/~r/skranz_R/~3/XlQmru0U0mQ/Tools_for_Writing_Shiny_Apps.html"> Economics and R - R posts</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Recently, I have written and hosted several multi-user Shiny apps. One example, is <a rel="nofollow" href="http://taddle.mathematik.uni-ulm.de/" target="_blank">Taddle</a> that runs on my server at <a rel="nofollow" href="http://taddle.mathematik.uni-ulm.de/" target="_blank">http://taddle.mathematik.uni-ulm.de</a>. Taddle is a multi-user shiny app that offers a free and simple way to allocate seminar topics. (Next time you need to assign seminar topics, why not have a look at Taddle?)</p>
<p>I just wanted to briefly give a list of tools that I found very helpful to write and host those apps.</p>
<ol>
<li> <a rel="nofollow" href="https://www.docker.com/" target="_blank">Docker</a>: I run all my shiny apps in separate docker containers. If you search the web, you find several nice blog posts (e.g. <a rel="nofollow" href="https://www.r-bloggers.com/dockerizing-a-shiny-app/" target="_blank">https://www.r-bloggers.com/dockerizing-a-shiny-app/</a>) that explain how to do it.
<p> One of many great advantages of Docker containers is that you can update packages or Linux libraries for one app without risking that the update breaks another app that is running in a different container on your server.</p>
<p> Being not a Linux expert, I also find it very convenient that Docker allows me to experiment with different Linux settings and programs in a way that entails much lower risk than if I would install the programs directly on my server.</p>
<p> You can also easily start and stop specific apps and host them on different ports on your server. </p>
<p> Even though it took me some time to get started with Docker the benefits were huge.</p>
<p> Of course Docker is mainly useful if you host the shiny apps on your own server or rented linux machine. A simpler alternative is to use a dedicated hosting service for shiny apps like RStudio’s <a rel="nofollow" href="http://www.shinyapps.io/" target="_blank">shinyapps.io</a>.<br>

<li><a rel="nofollow" href="https://www.rstudio.com/products/rstudio/#Server" target="_blank">RStudio Server</a>: Sometimes my app works nicely on my Windows notebook where I develop it, but some error arises when I put it on the server (e.g. some necessary Linux library is not installed). <a rel="nofollow" href="https://www.rstudio.com/products/rstudio/#Server" target="_blank">RStudio Server</a> is a great way to debug your app via a web browser directly on your server. Thus, for testing purposes I typically use a Docker container that has RStudio server already installed and add Shiny server as described here: <a rel="nofollow" href="https://www.r-bloggers.com/some-tools-for-writing-shiny-apps/”https://hub.docker.com/r/rocker/rstudio/”" target="_blank">https://hub.docker.com/r/rocker/rstudio/</a>. If the app then runs in production, one can base it on a container without RStudio server, or simply turn-off access to RStudio by disabling its port.<br>
</li>
<li><a rel="nofollow" href="https://github.com/skranz/restorepoint" target="_blank">restorepoint</a>: I personally debug my shiny apps and other packages using my package <a rel="nofollow" href="https://github.com/skranz/restorepoint" target="_blank">restorepoint</a>. This means that I start most functions with a line like `restore.point(“function_name”)`. This allows me to easily find and correct errors post-mortem after the shiny app has stopped. Setting the option `restore.point.options(display.restore.point=TRUE)` also helps to locate the function in which the error has taken place.<br>
Like all my packages, you need to install `restorepoint` directly from Github. When you run your app in production just put the line `set.storing(FALSE)` to remove the speed reduction that restore points otherwise entail.<br>
</li>
<li>Learn and use HTML, CSS, javascript and jQuery: When I wrote my first Shiny apps, I knew R already quite well, but virtually knew nothing about web programming essentials like javascript, jQuery, CSS or even basic HTML syntax. This means I implemented almost everything on the server side with R code that used the standard shiny widgets. One can do a lot with pure R code, but sometimes it is really better not to use it as a hammer for everything.
<p>For example, if you decide in Taddle that students shall rank all seminar topics, they will see the following HTML table:</p>
<p><img src="https://i1.wp.com/skranz.github.io/images/taddle_rank.PNG?w=456" data-recalc-dims="1"></p>
<p>Students can rank their topics via the buttons in each row or by the keyboard up and down keys. While you probably could create and modify such a table using Shiny widgets only, I found it much more convenient to genereate it with direct HTML code and write the button and keyboard handlers directly in javascript.<br>

<li><a rel="nofollow" href="https://github.com/skranz/shinyEvents" target="_blank">shinyEvents</a>: As a subjective matter of taste, I like tradional event-based programming more than the reactive programming framework of Shiny. My R package <a rel="nofollow" href="https://github.com/skranz/shinyEvents" target="_blank">shinyEvents</a> allows to write Shiny apps using an event-driven programming style.
<p>It is quite simple to define on the R side custom events that correspond to arbitrary jQuery events which can be quite useful for custom UI generated by arbitrary HTML code.</p>
<p>You can also combine shinyEvents with the traditional features and reactive programming paradigm of Shiny. It is essentially just a wrapper with several helper functions, to facilitate an event-based approach.</p>
<p>Take a look at the <a rel="nofollow" href="https://github.com/skranz/shinyEvents/blob/master/README.md" target="_blank">README.md</a> on Github for some examples.<br>


<p><img width="1" alt="" src="http://feeds.feedburner.com/~r/skranz_R/~4/XlQmru0U0mQ" height="1"></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="http://feedproxy.google.com/~r/skranz_R/~3/XlQmru0U0mQ/Tools_for_Writing_Shiny_Apps.html"> Economics and R - R posts</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/9y0652n_F_Y" height="1"></a></div></ol>