Developing Web Apps in R using Shiny

Tattooed Geek
21 min readMay 27, 2020

In this tutorial, you will learn about the purpose of Shiny package in R, it’s fundamentals and how to develop a simple web application/dashboard in R. At the same time, you’ll also get introduced to a javascript based visualization package called Highcharter.

All the links to web apps developed by me mentioned in this article extensively use the above package Highcharter. It is very interactive and easy to use. You will know how easy and simple it is to develop a web app in R and how powerful it is.

In my opinion in Data Science and Analytics, it is really important to express what you have analysed and share your findings in the most subtle yet visually attractive way possible and building web apps, beautiful interactive dashboards are the best way to do that. This article will make you competent in exactly that if you know R and or still learning it. This article will let you expand your skillset and move a step higher and better in becoming a better data professional. I will add quite a few links to dashboards and web apps developed by me in this article which you can surely use for your reference and develop your own web applications.

Bonus Tip: One great tool I recently started using for writing and tasks such as plagiarism checker, grammar checker, Co-writer, paraphraser, summariser, and translator is QuillBot .

I wanted to try something similar and cheaper than Grammarly.

I took up its yearly premium for around $2/month (45% off) during the Year-end sale using coupon code — (HOLIDAY45), valid till December end. The price was literally dirt cheap compared to other writing tools I have used in the past.

Personally, it’s UI and UX is very simple and easy to use. So I just wanted to share this awesome, productive tool with you all. Do check it out and use it in your day-to-day writing tasks.

https://try.quillbot.com/

Best Productivity Writing tool for this month

SIDE NOTE:

I always make sure I share my knowledge and resources which helped me. So I will be adding a few links to my favourite courses below related to this post and which can help you experiment with this post on your own. My focus has always been to learn things in a practical manner, that is why DataCamp has always been my go-to place for learning from the very start. It’s just that in this manner you can actually learn faster and better. DataCamp also has an amazing library of Projects. They started this new service recently and it’s really amazing. DataCamp projects is another amazing thing which I keep doing from time to time. Make sure to give it a try. Just once try them and then you will understand why I love DataCamp so much.

DataCamp will be offering a first-month subscription for only $1 from today till 3rd Dec, 8 PM ET. Also, they are having a black Friday sale where Yearly subscriptions have 75 % off. This is the first time they have ever run a sale like this. So do make sure to go check out DataCamp. Also, DATCAMP CHEATSHEETS is a pretty handy and very useful tool which I use from time to time.

Firstly, If you are not familiar with the basics of the R language, I urge readers to go complete this amazing course by DataCamp on R Programming, and this is the course from where I started my Data science journey using R years ago. Trust me with this, these courses are worth your time and money or if you want to learn the complete data science fundamentals from scratch using R which includes Statistics and probability, Data viz, exploring the data, data modelling and machine learning and other important concepts, I strongly recommend this foundation course Data Science with R .

Building dashbaords with ShinyDashboard.

Building web apps with Shiny in R: Case Study

Intermediate interactive data visualization with Plotly in R

Building Dashboards with FlexDashboards

Building web apps in R using Shiny.

Building Chatbots in Python

Building Recommendation engines using PySpark

So this would literally be the best time to grab some yearly subscriptions(which I have) which basically has unlimited access to all the courses and other things on DataCamp and make fruitful use of your time sitting at home during this Pandemic. So go for it folks and Happy learning, make the best use of this quarantine time and come out of this pandemic stronger and more skilled.

We’ll cover the following topics:

  1. Introduction to shiny.
  2. How shiny works and the fundamentals of shiny.
  3. How to design the UI of a shiny application.
  4. How to develop the Server-side logic.
  5. A simple example of a shiny app.
  6. Use Case — Analyzing kaggle 2017 datascience survey data using Highcharter .
  7. Deploying your shiny app.

Do read it till the end, because I have explained developing a basic dashboard with an example at the end, so you can use that as a reference and experiment with it.

Also below are some of the dashboards I have developed over the years in R: You can use these as a reference to build apps too-

  1. Worldwide COVID-19 Tracker
  2. COVID-19 India Tracker
  3. Analysis of Indian Economy using Shiny
  4. Kaggle Data Science Survey data analysis app(The use case explained at the end of this article)
  5. Text message classification app(Spam or Ham).
  6. Analyzing Inflation Rates Worldwide dashboard

Here is another tutorial I wrote on using HighCharter and developing dashboards in R.

Here is another one where I have used HighCharter for analyzing the dataset I have used for the app explained in this article.

The above links will take you to the Github repositories of these apps, the deployed links to these apps are on their Github repo(s). So make sure to check them out and Fork them.

So let’s get started.

Introduction

You might have already heard about shiny, a well-known R package that is actually a web application development framework for R. You can use it to build interactive web applications, dashboards and so much more, like deploying your trained machine learning model as a web service etc. All of these things make this package provides an amazing and powerful web framework for R users to develop beautiful interactive dashboards, web applications and turn your analysis into interactive web applications.

One of the best things about shiny is that it does not require you to have prior knowledge of HTML, CSS or javascript to develop web applications. It is all builtin and has several functions to design a beautiful User Interface (UI) for your application. UI for the applications can be built completely using R or can be written directly in HTML, CSS, and JavaScript for more flexibility. The CSS framework which is used by shiny UI is based on Twitter Bootstrap. Shiny has pre-built output widgets for displaying plots, tables, and printed output of R objects. Outputs will change simultaneously as users modify inputs, without reloading the browser in an asynchronous manner. For example, the way AJAX works. Shiny uses a reactive programming model. After the development of the application, next is the task of deploying your shiny application. You can easily deploy the shiny app from your Rstudio IDE in minutes. It Requires only an account on http://www.shinyapps.io/.

Getting Started with Shiny

Now that you know that Shiny combines the computational power of R with the interactivity of the modern web so that you can build standalone web applications, dashboard, interactive documents and reports using R Markdown, and gadgets with this R package, it’s time to get your hands dirty yourself.

Fundamentals

Shiny is available on CRAN and you can download it with the install.packages() function in R like below:

install.packages(“shiny”)

After you have done that, you can load in the library and start by launching and checking out a Shiny example application, such as "01_hello":

runExample("01_hello")

The result of these lines of code makes it clear that Shiny applications have two separate components: a User interface and a Server script.

  1. The user interface is where you will design the layout of your application example, where to place the widgets, input elements such as textbox, slider, buttons, form elements and where to display the plots etc that is the frontend of your app.

2. The server script will consist of the serverside logic which will contain all under the hood R code to make plots, to reactively render plots on some user-based event, build outputs based on the user inputs in clientside dynamically etc and other logic.

There is bidirectional communication between the server and the UI to help each other. It can be mapped to a simple client/server communication architecture, where the server responds to the client’s requested data and resources. In Shiny, all this happens at a lightning-fast speed. This is because Shiny uses a Reactive programming paradigm. The inputs defined are reactive in nature which produce reactive outputs.

But what is the reactive programming paradigm exactly?

Reactive Programming: A Short Definition

Reactive programming is an asynchronous programming model which is concerned with data streams and the dynamic changes in the program. Reactive programs continuously interact with their environment. Reactive programs only work in response to external changes and events to mostly deal with accurate interrupt handling. Real-time programs are usually reactive. Today, most of the web frameworks follow a Reactive programming model. For example, Django framework, AngularJs, MVC model, view, controller-based web frameworks are the best examples of reactive programming. Reactive programming can facilitate changes in an underlying model which is automatically reflected in a view.

Shiny also uses reactive programming paradigm in the same way. The UI and the server are continuously in contact with each other, and whenever an event or change in input occurs, shiny keeps track of your R code to be re-executed, and the changes are automatically/reactively reflected and updated in the output. Reactivity automatically occurs whenever you use an input value to render an output object.

Shiny Inputs and Outputs Objects

The shortest possible single file shiny app template:

# app.Rlibrary(shiny) #loading the shiny package

ui <- fluidPage() #Object contains the UI of the app

server <- function(input, output) {} #server logic

# both UI and server code in same file

shinyApp(ui = ui, server = server) #running the app

The above is an example of UI and server-side logic in the same file i.e app.R.

In the above code, the function attached to the ui that is fluidPage() is a function for creating fluid page layouts. A fluid page layout consists of rows which in turn include columns. This is same as bootstrap(a popular frontend CSS framework). You will add elements to the UI as parameters to the fluidPage function.

ui <- fluidPage(#UI of the app is defined here  # *Input() objects
# *Output() objects
)

The complete shiny application is built around the input and the output elements. Input can be anything ranging from a select input, checkboxes, radio buttons, text field, button, sliders, form elements etc. Outputs can be plots, tables, some text etc which are defined and changes reactively as the input value changes etc.

You will learn how to add elements to the UI and telling the server how to assemble the inputs and outputs in the below sections in more detail.

In Shiny, you can build and maintain your app with the ui.R file and server.R script separately, or you can build the entire app in a single file app.R like shown above. It depends on the size and complexity of your application. For large complex applications, you should prefer the modular way of keeping everything separate like shown below. Keeping UI and server files separate will make it easier to manage the code and application.

Now to start building the shiny application in R, you just need to open up you Rstudio IDE, go to File -> New File -> Shiny Web App and this is it. RStudio will first ask you the details of your application and there you can select whether you want a single file app or multiple files app.

Create a. new Shiny application in RStudio IDE

Now deploying a single file shiny app and a multiple file shiny app is exactly same and simple. You can simply deploy it from your RStudio IDE which will be explained later in the last section of this tutorial on Deploying your app.

To run your application, if your application resides in a directory ShinyApp/, you can launch it with:

runApp("ShinyApp") function with the directory name of the app as an argument.

ui.R

  1. *Inputs()- create an input using this function. Every *Input(inputId,label,....) the function takes the first parameter as an input id, using which it’s value will be accessed in the server script to add reactivity. Add the type of input you want and prepend it to *Input, for example- To make a slider input sliderInputs(), to make a select Input selectInput() etc. There are lots of input functions such as checkboxInput(), dateInput(), fileInput(),numericInput(), passwordInput(), textInput(), radioButtons() etc.

For example:

library(shiny)
sliderInput(inputId = "slider",
label = "Select a number",
value = 10,
min = 0,
max = 100 )
Slider Input

The above is what is produced from the above slider Input.

selectInput(inputId="selctid",label="Select",choices=c("R","Python","Tensorflow"))
Select Box
#use ?selectInputs to read the documentation and explore more about using these input functions

This is how you will create a reactive input in the UI of your application.

2. *Output()- use this function in the ui.R file to generate reactive outputs and view them in the app. Function takes output id as a parameter *Output(id). This output id will be used in the server script to write the R logic to display the type of reactive output you want. Prepend the type of output you want to the *Output() as, example-PlotOutput(),imageOutput(),tableOutput(),textOutput() etc are some of the most used output functions. example-plotOutput("scatterPlot") is how you will declare an output in the UI.

A simple demonstration- A general ui.r file would look like this. When using separate files you can use shinyUI() the function to start with designing the UI.

Divide the UI into 3 parts-

  1. Header — Use headerPanel() to add the app title.
  2. Sidebar Section — consists of the widgets and the input variables to control the output. Use sidebarPanel( *Inputs() ) to add input objects to the sidebar.
  3. Main Section — display the outputs such as plots, text etc in this section. Use mainPanel( *Output() objects) to define output objects.
library(shiny)

## Define UI for your application
shinyUI(pageWithSidebar(

# Application header
headerPanel("My first Shiny app") ,


# Sidebar Panel to place the inputs and widgets and control the output
sidebarPanel(
#slider input
sliderInput(inputId = "slider",
label = "Select a number",
value = 10, min = 0, max = 100) ,

#a select input
selectInput(inputId="selectid",label="Select the tyoe of plot",choices=c("ScatterPlot","Histogram"))
),

#main panel to display the outputs
mainPanel(

#display the reactive plot build from the inputs
plotOutput("plot") ,

#display some text
verbatimTextOutput("text") # no , required to end the last
# element of a section
)# end mainPanel

) #end PageWithSidebar

) #end ShinyUI

Notice the , a comma after every section and every input and output element expect the last element in the section. Like there is no , after verbatimTextOutput("text") as it is the last element of mainPanel(). It is important to add , otherwise the app would not run and show errors.

Combining all of this together, the steps are the following:

  1. Begin each app with a simple shiny template as explained above.
  2. Add elements as arguments to functions such as headerPanel(), sidebarPanel(), mainPanel().
  3. Generate reactive inputs with an *Input() function.
  4. Display reactive output with an *Output() function in the UI.
  5. Assemble outputs from inputs in the server script.

Server.R

Now you have to just assemble the inputs and outputs at the server-side script to add reactivity and the events which will occur. The server script will consist of all the actual R code and logic of the app. The basic task of a Shiny server script is to define the relationship between inputs and outputs. The server script does this by accessing inputs to perform computations and by assigning reactive expressions to output slots.

You have to start off with writing the server function. And this function takes parameters as input and output elements. server<-function(input,output){ #Rcode }

  1. Accessing input using the input object and generating output by assigning to slots on the output object.
  2. Save objects to display to output$plot at the server side from the ui, remember plotOutput("plot") was the output object defined in the UI.
  3. Build and generate objects to display using render*({#r-expressions}) function. There are different types of render functions based on the type of output you want to build. Such as renderPlot(),renderTable(),renderText(), renderUI() etc.The render*() the function is attached to the output object in the server script.
  4. Access input values defined in the UI using input$slider. Here slider is the id given to the input object created in the UI as sliderInput(inputId="slider",....).The input value changes whenever a user changes the input.

Below is a simple example to build a simple histogram.

server<-function(input,output) {

output$plot<- renderPlot({

hist(rnorm(input$slider))

})
}

This is how a simple server script would look like. Create reactivity by using Inputs to build rendered Outputs. Reactivity automatically occurs whenever you use an input value to render an output object.

Below is the demonstration of the above-explained shiny application.

Example

Let’s go step by step. Follow the steps given below each time you start making a shiny application. This will help you incrementally build an app and not mess up and avoid errors.

Creating an empty shiny app

  1. ui.R - create an empty layout and design the UI of your app.Divide the UI section into 3 different parts.
  2. Header — Use headerPanel() to add the app title.
  3. Sidebar Section — consists of the widgets and the input variables to control the output. Use sidebarPanel( *Inputs() ) to add input objects to the sidebar.
  4. Main Section — display the outputs such as plots, text etc in this section. Use mainPanel( *Output() objects) to define output objects.
 shinyUI( pageWithSidebar(

# Application header

#Side bar panel-inputs such as selectbox,widgets etc goes here

#main panel-Reactive outputs are defined and displayed here


) #end pageWithSidebar
) #end shinyUI

Now add header panels, sidebars and main panels using headerPanel(),sidebarPanel(),mainPanel() functions.

shinyUI( pageWithSidebar(

# Application header
headerPanel(title="My first Shiny app") ,

#Side bar panel-inputs such as selectbox,widgets etc goes here
sidebarPanel(),

#main panel-Reactive outputs are defined and displayed here


mainPanel()

) #end pageWithSidebar
) #end shinyUI

NOTE: notice no , after mainPanel(), as it is the last element of pageWithSidebar() object.

Congratulations, now you have created and defined the basic structure of your application’s UI. You only need to define input and output objects inside the UI now.

All the functions used in the ui.R expect a default argument, without adding anything as an argument, the empty functions would give an error saying- Error:argument "sidebarPanel" is missing, with no default. So it is important that you comment out these functions initially if you have not added anything inside them.

Don’t forget to add , after every section. Sometimes the errors arising due to missing , after a section can be really hard to debug.

let’s build and place the input and output objects in the UI.

## Define UI for your applicationshinyUI( pageWithSidebar(

# Application header
headerPanel("My first Shiny app") ,

# Side bar for inputs
sidebarPanel(
sliderInput(inputId = "slider",
label = "Select a number",
value = 10, min = 0, max = 100) ,



#a select input
selectInput(inputId="selectid",label="Select the type of plot",choices=c("ScatterPlot","Histogram"))
),


# The main panel will contain the outputs
mainPanel(
#display the reactive plot build from the inputs
plotOutput("plot") ,

#display some text
verbatimTextOutput("text")
) # end mainPanel

) #end pageWithSidebar
)#end shinyUI

Now you have defined and placed the input and output objects in the UI of our application. You can design and structure the layout of your application in any way you want, it only requires your creativity and designing skills.

Do check out the documentation of the functions used above to build inputs and outputs using an example-?sliderInput to get to know more about these methods.

Let’s summarize what you have done till now:

  1. Begin each app with a simple shiny template as explained above.
  2. Add elements as arguments to functions such as headerPanel(), sidebarPanel(), mainPanel().
  3. Generate reactive inputs with an *Input() function.
  4. Display reactive output with an *Output() function in the UI.
  5. The only thing left now is to assemble outputs from inputs in the server script.

Finally, let’s start with server.R and add some server logic to assemble inputs and output objects to add reactivity.

Follow these simple steps-

  1. Start off with defining the server function which takes parameters as input and output elements. server<-function(input,output){ # R code goes here }
  2. Save objects to display to output$plot at the server side from the ui, remember plotOutput("plot") was the output object defined in the UI.
  3. Build and generate objects to display using render*({#r-expressions}) function. There are various other kinds of render*({}) functions in R to render different outputs.
  4. Access the values stored in input objects defined in the UI using input$slider at server side. This is the key logic which adds reactivity. Here slider is the id given to the input object created in the UI using sliderInput(inputId="slider",....).
#server function takes input and output objects as argumentsserver<-function(input,output) {

#building the plots
output$plot<-renderPlot({

if(input$selectid=="ScatterPlot") {
#plotting the histogram
plot(rnorm(input$slider),rnorm(input$slider),xlab="Numbers",ylab="Count",col="red",border="black")

} else {

#plotting the histogram
hist(rnorm(input$slider),col = 'darkgray', border = 'white')

}

}) #end output$plot

#building the textOutput
output$text<-renderPrint({
#summary statistics
summary(rnorm(input$slider))

}) #end output$text

}

Output

When you run the above application you will get the following output-

The above app produces this output

This was a simple example of how a shiny app would look and work.

Use Case

Kaggle data science survey App

In this section, you will build a simple shiny application to analyze and visualize the Kaggle data science survey data. The dataset can be downloaded from Kaggle Data science survey-2017. Let’s start building the application.

You will use the Highcharter package for R to build plots. Highcharter uses the base function hchart() as the function to build plots. This function is similar to the qplot() from ggplot2 package. Read more about the package at Highcharter.

One thing to notice is that when using highcharter with shiny, you need to use 2 functions-

  1. To define the output plot in UI- highchartOutput(output_id) instead of plotOutput() function.
  2. To build the plot at the server-side use- renderHighchart({}) instead of renderPlot({}) function.

Let’s begin.

UI of the app

shinyUI( pageWithSidebar(

# Application header
headerPanel("Kaggle Data science survey data analysis") ,

sidebarPanel(
#select country
selectInput(inputId="country",label="Select the Country",choices=c("United States","India","United Kingdom","China","Germany","France"),selected = NULL)
),


#the main section to display plots in tabs
mainPanel (

tabsetPanel(type = "tabs",
#tab1
tabPanel("Job Titles of participants",
highchartOutput("plot1")

),

#tab2
tabPanel("Preferred tools",
highchartOutput("plot2")

),

#tab3
tabPanel("Preferred ML technique at Work",
highchartOutput("plot3")

)
)#end tabsetpanel

)#end mainpanel

) #end pageWithSidebar
) #end ShinyUI

Server script and logic of the application

You will first start off by storing the dataset at the location where your application files are inside your application folder. Now you will read the dataset in server script and perform necessary data transformation and pre-processing as per the requirements of your application. One of the best packages in R to do data-wrangling and data-transformation is dplyr , and this is what you will use in this case study.

Dplyr is built around 5 functions. These functions make up the majority of the data manipulation you need to do. You might need to:

  1. select() certain variables of data.
  2. filter() your data to select specific rows.
  3. arrange() the rows of your data in a specific order.
  4. mutate() your data frame to make new columns.
  5. summarise() chunks of your data in some way.

These functions are going to be used majorly inside the server script to do data manipulation.

In the server script shown below, you will first make a new filtered dataset countryJobs containing specific countries which you want to plot which are grouped by CurrentJobTitle variable and summarise them with total count using summarize(total=n()) function in R and then arrange them in descending order of total counts using arrange(desc(total)) function.

Then in a similar manner, you will create another data frame named countryToolDf in which you will group by a variable MLToolNextYearSelectwhich contains the tools used by the survey participants then filter it for specific countries passed-in filter() function and the rest is the same procedure. You summarise and arrange it in descending order.

You will then create another new data frame named countryMethodDf which will consist of the total count of most preferred machine learning technique used at workplace corresponding to each country by the survey participants.

Now, these new data frames will be used inside the server function to filter data based on the selected user input.

So the data transformation and pre-processing are done. Now you will start writing the server logic inside the server<-function(input,output) { #logic } function.

#requiring necessary R packages

library(shiny)
library(data.table) #for faster data reading
library(highcharter) #visualization package based on javascript
library(dplyr) #for data-transformation and data-wrangling


SurveyDf<-fread("Datasets/multipleChoiceResponses.csv")

#new filtered dataframe of country and corresponding count of job titles of survey participants
countryJobs<-SurveyDf %>% group_by(Country,CurrentJobTitleSelect) %>%
filter(Country %in% c("United States","India","Russia","United Kingdom","China","Brazil","Germany","France","Canada")) %>%
select(Country,CurrentJobTitleSelect) %>%
summarize(total=n()) %>%
arrange(desc(total))

#assigning NA value to missing values
countryJobs[1:2,]<-NA

#excluding NA values
countryJobs<-na.omit(countryJobs)

#making data frame for the tools used by countries participants
countryToolDf<-SurveyDf %>% group_by(Country,MLToolNextYearSelect) %>%
filter(Country %in% c("United States","India","United Kingdom","People 's Republic of China","Germany","France")) %>%
select(Country,MLToolNextYearSelect) %>%
summarize(total=n()) %>%
arrange(desc(total))

#assigning missing values as NA
countryToolDf[c(1,2,10,11,12,13),]<-NA

#excluding NA values
countryToolDf<-na.omit(countryToolDf)


#making a new dataframe for countries and their most used ML techniques at Work place
countryMethodDf<-SurveyDf %>% group_by(Country,WorkAlgorithmsSelect) %>%
filter(Country %in% c("United States","India","United Kingdom","People 's Republic of China","Germany","France")) %>%
select(Country,WorkAlgorithmsSelect) %>%
summarize(total=n()) %>%
top_n(20) %>%
arrange(desc(total))

#assigning missing values as NA
countryMethodDf[c(1,2,3,4,5,6),]<-NA

#excluding NA values
countryMethodDf<-na.omit(countryMethodDf)



#----------------------------------

#server function

server<-function(input,output) {

#job titles of participants plot
output$plot1<-renderHighchart({


#making a data frame of the selected country to use in plotting
df<-countryJobs %>% filter(Country==input$country)

hchart(df,type="bar",name="Count", color="purple",hcaes( x=CurrentJobTitleSelect,y=total)) %>%
hc_title(text="Barplot of Jobs titles of participants",align="center") %>%
hc_exporting(enabled=TRUE) %>%
hc_add_theme(hc_theme_elementary())

})


#most used Tool plot
output$plot2<-renderHighchart({

df<-countryToolDf %>% filter(Country==input$country)

hchart(df,type="bar",name="Count",color="red",hcaes( x=MLToolNextYearSelect,y=total)) %>%
hc_title(text="Barplot of Most used Tools and country",align="center") %>%
hc_exporting(enabled=TRUE) %>%
hc_add_theme(hc_theme_elementary())

})



#most preferred ML technique plot
output$plot3<-renderHighchart({

df<-countryMethodDf %>% filter(Country==input$country)

hchart(df,type="bar",name="Count",color="orange",hcaes( x=WorkAlgorithmsSelect,y=total)) %>%
hc_title(text="Barplot of Most used ML technique and country",align="center") %>%
hc_exporting(enabled=TRUE) %>%
hc_add_theme(hc_theme_elementary())

})



}

Output

Details about the various high charter package functions used above can be found using ?highcharter help documentation.

The link to the above application’s Github Repository can be found here Github: https://github.com/anishsingh20/Kaggle-Data-science-survey-data-analysis-Using-Shiny

Deployed App: https://anishwalia20.shinyapps.io/KaggleSurveyDataAnalysisDashboard/

Check the above link out to see this dashboard was built.

Hence this was a simple shiny application to visualize and analyze Kaggle survey data which shows you how to use highcharter package in R to build beautiful charts. You should definitely play around and find out more insights from the survey dataset using this simple app as a reference.

Deploying your application

Once you’ve built your shiny application, the next thing is to deploy it so that others can see your work and use the application. Rstudio provides a cloud platform which allows you to host your application on the web in minutes called shinyapps.io. It provides an amazing IaaS(infrastructure as a Service) which offers you the compute to host and run your shiny application for Free over the internet. You don’t need to own any kind of server. It has both free and paid options available.

You simply need to have an account on shinyapps.io, then it’s just the matter of minutes to upload your application over the platform and deploy it.Simply push-button publishing from RStudio IDE will do the needful. You need to follow this.

Below is an image which will guide you to deploy your application from your RStudioIDE.

So this is how you deploy your shiny application in a matter of minutes for free. Now the first 5 deployments are free on shinyapps.io, after that you will have to pay to deploy your application. More details regarding shinyapps.io can be found at this link shinyapps.io documentation and user guide.

Shiny in production

Other options to deploy your application in production with more compute power, active hours, more number of instances and most importantly in a more secure, scalable and fault-tolerant environment include the below options which are paid–

  1. Deploy on-premises (open source): Shiny Server-It helps you deploy your Shiny apps and interactive documents on-premises with open source Shiny Server, which offers features such as multiple apps on a single server and deployment of apps behind firewalls.
  2. Deploy on-premises (commercial): Shiny Server Pro- Using this scheme you can deploy your apps on-premises which offers a controlled production environment with the security, control, and support that workgroups and enterprises need. Shiny Server Pro supports a variety of password authentication schemes and a centralized management console for all your apps. They have two commercially licensed platforms for deploying on-premises. They are both designed for maximum scalability and security, and they offer authentication and monitoring features.
  3. RStudio Connect-New publishing platform for the work your teams create in R. With RStudio Connect, you can share Shiny applications, R Markdown reports, dashboards, plots, and more in one convenient place with push-button publishing from the RStudio IDE. Features include scheduled execution of reports and flexible security policies to bring the power of data science to your entire enterprise.

More details about the above details can be found at-https://shiny.rstudio.com/deploy/.

References

Hence this was a simple tutorial on using the shiny package in R to develop web applications for data analytics and data science projects to effectively communicate the results and your key findings.

Below are some of the references and materials useful for learning more on developing a shiny web application.

  1. This course on Building Web applications in R using shiny by DataCamp would be the best option to get started with learning Shiny.
  2. Shiny Tutorial.
  3. Shiny Cheatsheet
  4. Deploying a shiny app
  5. Highcharter Documentation

Hope you all liked the tutorial. Do Like and share Cheers!!.

--

--

Tattooed Geek

Main-Blog:https://medium.com/@anishsingh20 / | Medium Top Writers(India) | Solopreneur | Founder@DataInksights | Medium 150,000+ views/70,000+ Reads - monthly