<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/shiny-based-tablet-or-desktop-app/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.mango-solutions.com/wp/2017/03/shiny-based-tablet-or-desktop-app/"> Mango Solutions » R Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
Mark Sellors<br>
Head of Data Engineering
</div>
<p><strong>Turn a shiny application into a tablet or desktop app</strong></p>
<p>Since we first demoed it at our really successful trip to Strata London last year, a few people have asked us how we made the awesome looking <a target="_blank" rel="nofollow" href="http://dsradar.com/">Data Science Radar</a> app that we were running on the tablets we had with us. In this post we’ll take a look at how we did it, and hopefully show you how easy it is to do yourself.</p>
<p>Mango is primarily known for our work with the <a target="_blank" rel="nofollow" href="http://www.r-project.org/">R language</a>, so it should come as no surprise that this is the secret sauce used in the creation of the app. More specifically, we used a Shiny app written by one of our Senior Data Scientists, <a target="_blank" rel="nofollow" href="https://twitter.com/aimeegott_r">Aimee Gott</a>. The app uses the radarchart package which you can <a target="_blank" rel="nofollow" href="https://github.com/mangothecat/radarchart">find on github</a>.</p>
<p>I think the fact that it was written with Shiny has actually surprised a few people, largely because of how it looks and the way that we run it.</p>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/www.mango-solutions.com/wp/wp-content/uploads/2017/03/radar-screen.jpg"><img alt="radar-screen" class="wp-image-6653" src="https://i0.wp.com/www.mango-solutions.com/wp/wp-content/uploads/2017/03/radar-screen-300x189.jpg?resize=300%2C189" data-recalc-dims="1"></a></p>
<p>The tablets in question are cheap Windows 10 devices, nothing special, but we had to come up with a way of running the application that would be simple enough for the non-R-using members of the team. This meant that anything from the everyday world of R had to be abstracted away or made as simple to use as possible. In turn this means, not starting RStudio, or having to type anything in to start the app.</p>
<p>R and the required packages are installed on the tablets, ready to start the configuration that would allow the whole Mango team to use them in the high pressure, high visibility setting of a stand at an extremely busy conference.</p>
<p>We wrote a simple batch file that would start the app. This only got us part of the way though, because the default browser on Windows 10, Microsoft’s Edge, doesn’t have a full screen mode, which makes the app look less slick. We therefore changed the default browser to Microsoft’s IE, and put it in full screen mode (with F11) when it first opened. The good news here is that IE, remembers that it was in full screen mode when you close and re-open it, so that’s another problem solved. The app now opens automatically and covers the full screen.</p>
<p>The code for the batch file is a simple one-liner and looks like this:</p>
<pre>&quot;C:\Program Files\R\R-3.3.0\bin\Rscript.exe&quot; -e &quot;shiny::runApp('/Users/training2/Documents/dsRadar/app.R', launch.browser = TRUE)&quot;</pre>
<p>Next, it was necessary to set the rotation lock on the tablets, to avoid the display flipping round to portrait mode while in use on the stand. This is more cosmetic than anything else, and we did find that the Win10 rotation lock is slightly buggy in that it doesn’t always seem to remember which way round the lock is, so that it occasionally needs to be reset between uses. Remember, our app was written specifically for this device, so the layout is optimised correctly for the resolution and landscape orientation, you may want to approach that differently if you try this yourself.</p>
<p>We also found that the on-screen keyboard wasn’t enabled by default with our devices (which have a detachable keyboard), so we had to turn that on in the settings as well.</p>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/www.mango-solutions.com/wp/wp-content/uploads/2017/03/tablet-form.jpg"><img alt="tablet-form" class="wp-image-6654" src="https://i0.wp.com/www.mango-solutions.com/wp/wp-content/uploads/2017/03/tablet-form-300x199.jpg?resize=300%2C199" data-recalc-dims="1"></a></p>
<p>Having the application start via a Windows batch file, isn’t the prettiest way of starting an app as it starts the windows command prompt before launching the application itself. This is hidden behind the application when it’s fully started, but it just doesn’t look good enough. This problem can be avoided with a small amount of VBScript, which runs the contents of the batch file without displaying the command prompt. Unfortunately the VBScript icon you end up with is pretty horrid. The easiest way to change it is to create a shortcut to the VBScript file and then change the icon of the shortcut, which is much easier.</p>
<p>Here’s the VBScript:</p>
<pre>Set objShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
objShell.Run(&quot;C:\Users\training2\Desktop\dsRadar.bat&quot;), 0, True</pre>
<p>Check out the video below to see it in action, we hope you agree that it looks really good and we hope you find this simple method of turning a shiny application into a tablet or desktop app as useful as we do!</p>
<p><iframe height="315" width="450" allowfullscreen="allowfullscreen" src="https://www.youtube.com/embed/QkR1d_HnJHA"></iframe></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://www.mango-solutions.com/wp/2017/03/shiny-based-tablet-or-desktop-app/"> Mango Solutions » R Blog</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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/W0z8flhvzIE"></a></div>