 Hi everyone, so today we're going to be talking about R Shiny and why you should turn your R scripts into interactive web applications. So first of all, what actually is R Shiny? Shiny is an R package which allows you to build interactive web applications without any other knowledge of web development. The Shiny app is always maintained by a computer running R and this can be either locally on your PC or on a hosting platform like shinyapps.io. The benefit of using a hosting platform is that it means that your application can be shared with anyone as long as they have an internet connection and they can access that website. Shiny apps have two main components. They have a user interface which is what you see when you go onto the application and it's what the user interacts with and they also have a server which is instructions for what the computer should do in the background. So it's sort of the processing side of things. When a user inputs something within the user interface it gets processed in the server and it usually leads to some sort of change in the output on the application. I wanted to show you under the hood of a really simple Shiny app just so that you understood a bit more about what's going on within these elements. So let me share this video here. This is a simple Shiny app where the user inputs a region of interest, so America, Europe, Asia. And then you can see on the right hand side there's a bar plot showing the number of telephones within that region over time. Here you can see the title panel that corresponds to the title of the app. You can see the side bar layout and importantly you can see the select input option here which is generating that drop-down list that the user can select an option from. So you can see within this that the choices for this drop-down list come from the column names of this dataset world phones which is already loaded in our studio generally and it comes from the datasets package. So then we've also got some a break in the text and then some help text is written as well just to describe to the user where the data comes from. On the right hand side we have the plot output which is the bar plot showing the number of telephones and this relates to the server.r code that we have here as well. So what's happening here is this is outputting the phone plot which is the same the same ID is here so the plot output phone plot corresponds to this here in the server code and it's rendering a plot using the world phones dataset again but it's slicing to only include the columns which have been inputted in this select input option and then it's going to output the relevant bar plot. So this is a really simple example of how reactivity works in shiny where a user input then generates a specific output and this application and many many more are available on the RStudio shiny gallery. There's lots of really simple applications and more complicated applications on there and most of them have the code available for you to play around with. So now you understand a little bit more about what's going on behind a shiny app. Why would you actually want to learn to build it? Is it worth the effort involved in learning how to code in shiny? And here I wanted to present some examples from our research group and how we've used shiny in our own work. First of all, if you conduct large systematic reviews and meta-analyses you'll know that you typically generate quite a lot of data with a review and sometimes in a publication you can't really put all that data in there and you can't really visualize it all in the way that you might want to and also once you come to publish your research you ideally want to be sharing it somewhere so that it's accessible for other people to reuse that data and rather than putting it in CSV files in a repository just we also wanted to share it in another way that made it more engaging and accessible for the research community. So this is an example from a review of animal models of neuropathic pain where they induce neuropathic pain in animals and then try to treat it using various treatments as a way of modelling neuropathic pain. So you can see here, this is a couple of, here's a couple of doughnut plots. We've got the number of publications which use different models to induce neuropathic pain so 52 publications use pachylotaxyl which is a chemotherapy to induce neuropathic pain in the animals. You can see different numbers here and then we've got the same for treatments and we've also got the same for outcome measures where you can see the number of papers that use different outcome measures to measure the pain. Then some interactivity is built in here because you can actually select a certain model of interest so if I was a researcher interested in pachylotaxyl models maybe I would be filtering to look just at that. This is a select input box similar to the one we've seen in the previous Shiny app and here I've changed the output so it's looking only at the pachylotaxyl studies, you can see which treatments have been tested in those studies and which outcomes have been measured as well. Another feature I wanted to highlight in this application is it allows users to download data of interest so you could select a model of interest, let's select pachylotaxyl again, you can select all the drugs of interest and all the outcomes and you might want to only look at publications that are more recent so you could use a slider to filter and then you can download the data of interest and use it for your own review projects or whatever you want to use the data for. Another use case for making a Shiny app is that they can allow you to make your evidence synthesis tool accessible and this is probably pretty relevant for this conference as well. So I created a tool in R to deduplicate citations across different databases that were obtained during systematic searching and because I developed it in R I realised quite quickly that it was difficult to actually share with people unless they knew R as well or quite often then I would end up having to run it for them which isn't really that productive either. So to save everyone time I created a Shiny application to do this for them so I'll show you this now, it's quite a simple application, basically users can upload a file of their systematic search, they can go to the deduplication tab and they can click to deduplicate their references, this is one that's been already clicked as you can see so the tool's already removed a certain number of references and there's also an option for manual deduplication here which you can do on the app. Once you're happy with your unique dataset you can then download it and there's a few different options for exactly what you want to download. So this is quite a simple app actually, it's really just got an input, the app does something in the background, it processes the data and it deduplicates it and then finally the user can download the resulting dataset so it's really quite user friendly and finally as I got more experience with making Shiny apps we worked with some collaborators to start building what we call systematic online living evidence summaries which is sort of flipping the idea of systematic reviews a little bit. Essentially we're creating Shiny apps which house all the citations for a really wide ranging field so for example Alzheimer's disease or in this case the effects of pesticides on human health and animals and ecosystems so you take all of that citation data you can apply some automated tools to it using R as well and then you can display all that data visually on a user interface in Shiny and it means that then collaborators can go on and download the data that they want to. So this is another example and it's really more to highlight what Shiny can do. This is another Shiny app I won't go through all of it because I don't really have the time but this is one of the main functions so this is a database here a data table showing all of the citations you can actually search this database using keywords and Boolean and or options to a bit like PubMed but a bit more simple and then you can click to filter studies by lots of different options where you want the research to come from and whether you want it to be in animals or humans and lots of different options there and what year you want it to be published in and then you can download the data to different export formats as well. On this page I just wanted to highlight some of the visualization side of Shiny and some more visualization so this is a map visualization showing where the citations come from across the world and how many papers were published and coming from different countries and finally I also wanted to show this page because this app was a work in progress so there was actually reviewers working on annotating data in the background as well and to keep track of lots of different reviewers and how much work they've done we built this leaderboard functionality as well where you can see all the different reviewers and how many publications they've reviewed so moving back to this this really using Shiny enabled us to create a resource but for our collaborators and to visualize a lot of data and summarize it and gain insights from that so I also wanted to just highlight some of the key advantages of using Shiny so first of all it is geared towards those who have no web development experience it so if you already know or it's probably going to be quite easy for you to pick up Shiny at least initially and once you create your first shiny app it's really easy to host it online and share it with other people it's actually free to do this at least with quite simple apps on shiny apps.io but there's lots of other options for sharing it online as well also I like Shiny because it scales in complexity from beginner applications using all the ready-made functions available and like adding buttons and tables and sliders all those options are built into the Shiny package and the reactivity at the start is quite intuitive and it's simple whereas if you click this input this is the output that you'll get moving on to more intermediate functions of Shiny you can add on packages for more user interface customization you can make the reactive programming side of it really quite complicated so there's a lot of engaging content so if a user clicks a certain point on a plot maybe another plot's generated and you can do a lot to make it really engaging and finally if you want to produce more advanced production ready applications you can use modularization where you get chunks of elements that you quite often use in your application so for example maybe you always generate that sort of map for author country you could put that into a module and then use it for other applications as a chunk of code and it just makes it easier to sort of generate more applications along a similar line as well and you can also integrate html and javascript code in there this is particularly useful if there's some little element that you want to add or change within the website that there's not an R translation for yet and finally I wanted to share some top tips to get started with shiny and once you've installed the shiny package and loaded it from the library you can get started in about 10 seconds all you have to do is create a shiny web app from the new file option and then you just give it a name once you do that you'll be left with a script that already runs the web application so you can just click run app already and then you can it will produce an app in a new window and then from there you can modify it and run it again and modify it and run it again and sort of get to know what each part of the shiny app is doing the shiny package also comes with 11 examples for you to run and then you can modify them and I really found that probably the most useful when I was learning shiny is to just modify other people's applications first before you start writing your own and testing out all the different inputs and output options and really taking the time to understand how reactivity works in shiny so how do we go from a user input to an output on the application once you've sort of mastered those fundamental aspects of shiny you can then move on to customizing the layout and appearance and there's lots of packages which let you do that and let you really change the appearance of a shiny app and I also just wanted to recommend this book Mastering Shiny and by Hadley Wickham is available as a book down online and it's just a really useful reference guide for everything in shiny from really beginner level applications to more advanced functionality as well that's the end of my talk thank you all for listening and I'm really happy to take any questions about shiny I really hope that I've inspired you to create your own shiny app and to use it in your research