Making Shiny Apps Awesome

Estimated time:

A week before Christmas our CTO, Marek Rogala gave a speech about ways to make Shiny apps do much more than usual during <a href="" target="_blank" rel="noopener noreferrer">R enthusiasts meeting in Warsaw</a>. In case you have missed this event, we are brining you the gist. We often use R and Shiny to create interactive web apps for both internal and commercial projects. What makes those technologies so wonderful is the fact that they allow for easy prototyping of almost any data science problem. There are <a href="" target="_blank" rel="noopener noreferrer">numerous examples</a> of how Shiny can be used to make an interactive web app, so it’s pretty easy to find inspiration on how to build one by yourself. However, in our day-to-day work we are constantly challenged to do more that is currently possible in Shiny by default. Fortunately, both R and Shiny are highly extendable and <strong>Marek</strong> spoke about specific problems we were facing in past projects and what R packages we had created to solve them. <iframe src="" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe> <blockquote>The first problem was… <strong>creating a smooth user experience and good looking interface</strong>.</blockquote> Although Shiny is a great web framework it does not look beautiful enough for today’s web standards. As our data science team has also extensive web development experience and loved to use <a href="">Semantic UI</a> from the very beginning of its existence, we decided to combine it with Shiny. We have named this package <a href="" target="_blank" rel="noopener noreferrer"><strong>shiny.semantic</strong></a>. It allows us to create really good looking apps with interactive components, like rating bars or cards, which are missing in Shiny. In 2018 we went further, we created <a href="">semantic.dashboard</a> which is even more powerful. <img class="size-full wp-image-8032" src="" alt="Sample Shiny dashboard for churn analysis." width="2575" height="1408" /> Sample Shiny dashboard for churn analysis, built with shiny.semantic. All that you get by built-in methods or by adding a few simple CSS classes. But there is more! For instance, you have a huge set of <a href="" target="_blank" rel="noopener noreferrer">Semantic UI icons</a> and animations too. You can learn more about this package in <a href="">our previous post</a>. <img class="size-full wp-image-8033" src="" alt="Sample Shiny dashboard for fraud detection." width="2876" height="1492" /> Sample Shiny dashboard for fraud detection, built with shiny.semantic. The second problem we had to face couple of times was … <strong>an in-app navigation and state keeping</strong>. In today’s world we are used to making page bookmarks and sharing links with other co-workers. We also expect that app will keep its state, when opening it from a bookmark or shared link and we often want to navigate back in our browser to see a previous state. Unfortunately Shiny has a very limited support for those. As our blog’s reader you might already know how to solve the issue we created <a href="" target="_blank" rel="noopener noreferrer"><strong>shiny.router</strong></a> package. During the event Marek discussed details and history of package development. This simple library not only solves navigation issues mentioned above, but also encourages the user to write more structured and better code by writing UI modules. Last but not least, Marek presented our <strong>real-time collaboration solution</strong> for Shiny. Although Shiny does support this kind of reactivity, it is limited in many ways. In a regular Shiny app you may use global scope reactive values that are shared between multiple session and refreshed every time someone makes a change. There are some limitations though: <ul><li>state is not persisted, unless stored and initialized from database</li><li>this data cannot be used outside of Shiny apps, which makes it difficult to analyze the content in those reactive values</li><li>scalability - apps hosted on <strong></strong> can handle <a href="" target="_blank" rel="noopener noreferrer">a few hundred users</a> and Shiny Server Pro instance will support up to <a href="" target="_blank" rel="noopener noreferrer">200 users depending on a chosen license</a></li></ul> In order to solve some of those issues we have created a wrapper for Reactive real-time databases (eg. RethinkDB, Firebase). It allows us to easily recreate a state of an app (state can be easily stored per user) and all tables and reactive values are synced between multiple sessions. For example we can span multiple Shiny apps processes and connect it with one real-time synced reactive database. So to satisfy the requirement of 10 thousand concurrent users we just have to run 50 Shiny Server instances with a load balancer in the front. If you didn’t have a chance to hang out with Marek during R enthusiast event feel free to <a href="">get in touch with us</a> to talk more about any of these topics. :)

Contact us!
Damian's Avatar
Iwona Matyjaszek
Head of Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Have questions or insights?
Engage with experts, share ideas and take your data journey to the next level!
Join Slack
Explore Possibilities

Take Your Business Further with Custom Data Solutions

Unlock the full potential of your enterprise with our data services, tailored to the unique needs of Fortune 500 companies. Elevate your strategy -connect with us today!

Talk to our Experts
open source
shiny dashboards