Creating Web Applications with Interactive User Interfaces

- Pentaho

Introduction

Data visualisation is the representation of data as graphs or plots. Interactive visualisation enables decision-makers to interpret difficult concepts and recognise new patterns by seeing the data getting processed and changed into graphs live.

Shiny is a package from RStudio which provides a web application framework to easily build interactive web apps using R. The popularity of Shiny can be credited to its ease of working. Shiny is a perfect choice for users with no experience in web development as you do not need any prior knowledge of HTML/ CSS/ JavaScript.

Shiny Application

Installing the shiny package is a prerequisite. Every shiny app is built using two parts: a web page that displays the app to the user and a server that powers the app. A “UI.R” file creates the user interface in a shiny app and provides interactivity by dynamically taking input from the user and displaying the generated output. A “Server.R” file contains a series of steps to convert the input fed by the user into the desired output to be displayed.

The user interface comprises of:

Title Panel: The content in the title panel is displayed as metadata on the top left corner of the screen and provides the name of the app and other necessary information.

Sidebar Layout: It is present on the left side of the screen and accepts input from the user in the form of text, check-box, radio button, drop-down list, etc.

Main Panel: It is the part of the screen where the output is displayed.

Building the application

  • Load the shiny package in R.

library(shiny)

  • Shiny runs the code in ui function once when app is launched.

ui <- fluidPage()

  • Shiny runs the code in server function once each time a user visits the app.

server <- function(input, output){}

  • Input can be collected from the user in many formats. E.g: A drop down list created using the selectInput() function.

selectInput(inputId, label, choices, selected = NULL, multiple = FALSE, selectize = TRUE, width = NULL, size = NULL)

  • Output can be displayed in many formats according to the user’s desirability. E.g: Display the output in table format.

tableOutput(outputId)

Conclusion

Shiny makes it possible to deliver real-time output for a given input. Shiny is used to visualise complex data like 3D plots, heat maps, etc. Shiny has the ability to incorporate HTML and CSS codes as part of its UI and this is a huge plus. Shiny helps to develop applications in which the user has complete control of what they want to visualise.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>