After learning R for a few months, the code wasn’t looking quite so much like gibberish and I was becoming more curious about how to share these data insights on a wider scale, other than a static report.
The challenge with the report approach of course is you spend time creating something for a specific scenario and if the business user has a resulting question, they may need to come back to you, with their query/request to view whatever it is they need and suddenly the business user is waiting for you, while you now have another task, to create another report with the specified one off metric and when that’s done, you’ll probably get another request. This is a vicious and unrelenting circle.
Spending the time to understand Shiny can help build web based applications and make you shine, allowing the user to self engage the data and answer their own questions. Then you can spend your time doing the important stuff, building the cleaning and wrangling script code so the required options are available for all users, rather than just one.
Having had experience inside a large retail business I KNOW this skillset is under-represented and will have growing demand in the future as data surrounds us. For those willing to spend the effort to learn the required skills there will be benefits as you can create greater value for your employer, whoever that may be.
I suppose there are a few more skills required if you want to be able to share your app widely, you’ll need to be able to work with R to prepare the data, write Shiny code to make the interactive dashboard, find a way to deploy this online and probably ensure there is some kind of authentication.
For now I’ll introduce you to Shiny and some examples of Shiny dashboards in this gallery.
The code to create a Shiny dashboard is amazingly intuitive if you are starting with a basic app, which consists of a user interface file and server file.
Below I’ll give you an example of a very simple single file Shiny app, which you can paste into Rstudio and run.
# Install Shiny if required, otherwise it will just load it
if(!require(shiny)) install.packages("shiny", repos = "http://cran.us.r-project.org")
## Loading required package: shiny
# Global variables can go here
n <- 200
# Define the UI
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
plotOutput('plot')
)
# Define the server code
server <- function(input, output) {
output$plot <- renderPlot({
hist(runif(input$n))
})
}
# Return a Shiny app object by uncommenting the below (congratulations!)
# shinyApp(ui = ui, server = server)
Rstudio has a great tutorial that you can start to work through here. Don’t expect to master this overnight, it will take some applied effort. When you fail, which you will, you’ll be one step closer to understanding coding Shiny and a step ahead ahead of those that give up at the first hurdle.
I’ll save the self deployment of shiny apps through your own instance for another article as this will be a bit lengthy in itself but you can deploy your apps using Shinyapps.io which is also owned by Rstudio. They have pricing tiers for very low usage at $0 right through to enterprise plans that include the authentication and load balancing you will need at some point. By publishing even this example app through them, you will get to see just how easy it could be to share your data insights through dashboards in the future.
Having seen the power of sharing insights like this my regret is I wasn’t introduced to R and Shiny earlier in my career. I wasted so much time learning excel rather than mastering this language, which can be applied across many segments.
If you want some more inspiration, here’s one more link through to the 2020 Annual Shiny Contest where you can see the broad assortment of use cases competitors put forwards this year.