Resources

Dominik Krzemiński | Appsilon's Guide to Working With Open Source Shiny | RStudio

From rstudio::global(2021) Shiny X-Sessions, sponsored by Appsilon: There is no need to praise Shiny for its influence on interactive data visualisation. As with many other technology stacks, Shiny could benefit from community contributions for the further development of the package itself and the growth of independent packages that add new features. In this talk, I present some of the most popular Shiny extensions and explain what are the ways to help with developing Shiny-related tools. About Dominik Krzemiński: Dominik is the Open Source Tech Lead at Appsilon where he enjoys contributing to open source tools, mainly in R and Python. He created shiny.i18n, shiny.semantic, and the TODOr package for R. He also participated in the Google Summer of Code, where he developed tools supporting neuroscience analyses. He’s also a fan of all kinds of board sports and capoeira. Learn more about the rstudio::global(2021) X-Sessions: https://blog.rstudio.com/2021/01/11/x-sessions-at-rstudio-global/

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Welcome everyone, and in my talk I will discuss some aspects of Shiny Open Source, but before we move on, let me briefly remind you why our community praises Shiny so much.

First of all, you can prototype your applications very fast, so you can create your first POC in a matter of hours rather than days. That all comes wrapped in a neat user interface powered by Bootstrap, so you don't really need to reinvent the wheel when it comes to styling. Obviously, you can customize it as it was shown in the previous presentations. Shiny leverages the power of R when it comes to the data analysis, so in the backend you can use those powerful packages from the Tidyverse family, for instance, and Shiny also is nicely integrated with a large number of visualization packages like ggplot, leaflet, datatable, and even more. Interactivity, so how different UI components talk to each other is quite easy to understand, but with all those advantages in mind, sometimes I have the impression that we forget that the true power of Shiny lies in the fact that this is fully open source software, and I came to realize that recently when I was reading again through a blog post describing the winning solutions to the second annual Shiny contest, and I realized how many different applications you can actually use Shiny.

So here we have an interactive data storytelling, we have a machine learning-backed application for visualizing your musical taste, we have data analysis dashboard that presents the most popular GitHub repositories, and finally, you can even make games as proven by our very own Pedro. But all of that wouldn't be really possible without all of those Shiny extensions that are available now, and every year there's even more and more of them.

So there is no way that I could cover all of them in detail during my 10-minute slot, but I decided to cherry pick just a few, without which I can't even start thinking about starting developing my own Shiny applications.

So let's kick off with ShinyJS, which is a package from Dean Attali that lets you perform common, useful JavaScript operations in Shiny, like hiding elements, disabling inputs, resetting values, or alerting some variables that I often use for debugging myself. The cool thing, though, is that you don't really need to know any JavaScript to start using that, because everything is wrapped in R functions that are nicely documented, so it's quite easy to get started.

Then we have Shiny Widgets, which is basically a collection of extra components to enhance your Shiny applications. The repository contains a big selection of the components that are usually nicely documented with little code snippets, such that you can copy and paste the code and adjust it for your own needs. Some of my favorite elements are, for example, picker input, those fancy checkbox button, or horizontal multiple choice selector.

Then we have small but rather powerful package, Shiny CSS Loaders, that helps you with adding loading animations to the output instead of greening them up. So I mentioned to you already that Shiny uses this power of R for data analysis, but certain actions can take a while, so it's better to provide our user with some feedback that there's something happening in the background. So you can do it with a simple one-function call with Spinner that adds to your Shiny those little animations.

OK, and I wouldn't be myself if I haven't mentioned about some packages that help you style your apps. As in Appsilon, we care a lot about how the apps look. So starting from the left, we have BS4Dash that provides you with bootstrap for admin LTE skin for your dashboards. Then we have Shiny Mobile that helps you create mobile-ready Shiny apps that look almost like native apps for iOS and Android. And then on the right, we have our own Shiny Semantic that helps you to attach an alternative look to your Shiny applications.

OK, and I mentioned that I just scratched the surface here, so there is even more fantastic Shiny extensions that you can find on this Shiny Awesome repository that I discovered recently. And this little repository summarizes and categorizes various Shiny extensions such that you can always find something that you need there. I encourage you to check it out.

How to contribute to open source Shiny

OK, but using all those Shiny extensions is just like one way how you can take advantage of Shiny open sourceness, but you can help yourself with building those tools.

So first of all, you can start from something as simple as reporting a bug or bringing some new idea to the table by creating a new issue on GitHub repository or emailing an author of the code. But remember to be respectful with that, as very often open source code is created by enthusiasts, or as in our case, this is something that we do outside of our daily work with clients.

Then, if you feel comfortable enough actually to fix some bug or contribute with a new idea to a certain package, feel free to do some coding and create a new pull request. But remember first about reading and contributing guidelines, as they usually contain useful information with what to do or not to do on a given repository. Remember about testing all of your changes so that you see that you didn't break all the previous functionalities of the code and always ask politely for a review. It's good to have another pair of eyes to check the quality of your code.

Creating your own package

OK, but now if you still see that there is no solution to your problem available, then you can move on and think about creating your own package. And remember that for starters, it doesn't really need to be perfect. Some solution is better than no solution whatsoever. And always you may find someone in the community who would be interested in collaborating and moving the project forward if you don't really have time to do all the coding on your own.

And then a couple of tips from me. Remember about adding tests to your package from the early beginning, as it will really spare you so much troubles at the later stage of the development. Remember about documenting your code. For you, it might be quite obvious how to use your own functions, but not necessarily for the users of your package. And recently, it became a good practice to add interactive examples to your repository such that users can test what this package actually can help them with before they even download it. And then comes the fun part. So remember about publishing it, sharing with others to get credits and acknowledgements. It's a really satisfying feeling.

And recently, it became a good practice to add interactive examples to your repository such that users can test what this package actually can help them with before they even download it.

Appsilon's open source Shiny packages

OK, with that, let me mention our very own Appsilon open source family related to Shiny. So you have a variety of packages here related to styling, packages that help you with debugging, translations and routing. I will not go into too much detail here, as we have a separate pre-recorded video available where I discuss some of the possibilities of those packages and a little bit more details. Just let me mention here that every year we try to extend this list. So stay tuned as later on, Filip and Marek will tell you a little bit more about our two new projects.

OK, so to sort of like prove to you that our packages can be useful, a couple of months ago, we decided to challenge ourselves and try to implement a fully functional Shiny applications in less than 24 hours. So here you have a screenshot from two out of like six entries to this little competition for the comprehensive list of all the amazing solutions. You can check our blog post.

And if you can wait and you still want to see all of our packages in action, I encourage you to visit Shiny Tools website that we set up recently. And it contains references to the GitHub, to the documentation and live examples of all our packages. So we can test them if they can be useful for your Shiny development.

OK, so that's all I get. Thank you very much for your attention. Feel free to ping me if you have any questions and I hope you will enjoy the rest of the session. Cheers.