Interactional histogram on Rshiny and deploying app on website

There are many ways to create interactive visualizations, dashboards, and applications for business users who may not have the programming skills or interest to work in R. However, Shiny lets R developers generate interactive data visualizations for the web directly, with as much or as little GUI richness as they choose to invest. It dis-intermediates the relationship between data scientists and business users, resulting in high fidelity iterations and a timely, high-quality interactive data experience without (or with much less) web development and without the limitations or cost of proprietary BI tools. 

A Shiny application consists of two parts: ui and server. UI is where we can design user interface and server is where we assign tasks according to user choices. Let say we want to generate a histogram of Salary depending on selections of Job Role, Experience and Area. In the UI file, we will call three inputs, according to Job Role, Experience and Area. Input forms could vary from date range to check box or select button. In this case, we should choose dropbox selections, so that the options for each section will be automatically updated when the data changes. After that, we call the output name and place it at the main output panel.  

The most important thing that makes our histogram interact with any changes in the choices of users lies in the server file. We will filter data depending on users’ selection of each Job Role, Experience and Area; therefore, we will have three sub-datasets, the last of which will be used to plot histogram. For each time we filter the data, pass process through reactive{()} function, so that final data will then be iterated whenever JobRole, Experience or Area changes.  

After having the data and linking input in the UI file with data from the server, we will use the filtered data to generate a histogram. Since our histogram data is of continuous value (Pay), we have to set the number of bins. There will be problems if the data observes outliers. To aggregate all outliers to the first and last bin, we use the quartile threshold. Call the output name in the server file and draw histogram with ggplot inside renderPlot({}) expression, we have finished our server file. 

Here, we have completed the Shiny app that could run on a separate window and be ready to be used in a user-friendly interface. However, to deploy the app on an existing website, we have to host UI and server files on cloud with, then use < iframe> to embed the app to website code. 

Ha Nguyen

Get free consultation from our tech experts

Get free consultation from our tech experts

Schedule a discussion
Get free consultation from our tech experts
Get free consultation from our tech experts

Related articles you may would like to read

Connect With Us

Request a Consultation