server <- function(input, output) {
output$distPlot <- renderPlot({
ggplot(faithful, aes(x=waiting)) + geom_histogram(bins = input$bins)
})
}Deploy your app
SISBID 2026
https://github.com/dicook/SISBID
RStudio Connect and ShinyApps
- Sign up for an account on https://www.shinyapps.io/
- Authenticate your account
- Install the library rsconnect (this is the part that may require admin access to your machine)
- Follow the instructions on ShinyApps.io to authenticate and upload your first app!
Initiate
✅ Using the RStudio File menu,
- choose
New file, - choose “Shiny web app”
- Give it a name, and choose
Single file
This will create a folder in your workspace with the same name as you gave your app. It will also open the app.R file in your text editor pane.
🛑 Click the Run App button on the RStudio window.
✅ Click Publish to upload your app to the shinyapps.io server.
㊗️ You’ve just published your first app
Make it yours
Change the plot to use ggplot, this involves changing the server function to be this:
You will also need to add library(ggplot2) at the top of the file, just after library(shiny).
🛑 Click the Run App button on the RStudio window. (Fix any errors)
✅ Click Publish to re-upload your app to the shinyapps.io server.
㊗️ You’ve just published your first modified app
Make the plot interactive
Change from a static ggplot plot, to an interactive plotly plot, by
Change the server function to look like this. Note renderPlotly
server <- function(input, output) {
output$distPlot <- renderPlotly({
p <- ggplot(faithful, aes(x=waiting)) +
geom_histogram(bins = input$bins)
print(ggplotly(p))
})
}Change the ui function to render plotly output
mainPanel(
plotlyOutput("distPlot")
)Add library(plotly) to the top of the file.
🛑 Click the Run App button on the RStudio window. (Fix any errors)
Change the UI
Convert the slide into a numeric input, by changing the ui function to be:
sidebarLayout(
sidebarPanel(
numericInput("bins", "nbins", 30)
),(The numericInput replaces the sliderInput code)
🛑 Click the Run App button on the RStudio window. (Fix any errors)
✅ Click Publish to re-upload your app to the shinyapps.io server.
㊗️ You’ve just published your second modified app
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.