library(shiny)
library(bslib)
library(tidyverse)
library(plotly)
ui <- page_sidebar(
title = "A Simple Shiny App",
sidebar = sidebar(
sliderInput(
inputId = "bins",
label = "Number of bins:",
min = 1, max = 50, value = 30
)
),
card(
card_header("Histogram"),
plotlyOutput(outputId = "distPlot")
)
)
server <- function(input, output) {
output$distPlot <- renderPlotly({
x <- faithful[, 2]
gg <- ggplot() +
geom_histogram(
aes(x = x), bins = input$bins, fill = 'darkgray', color = 'white'
) +
labs(
x = 'Waiting time to next eruption (in mins)',
y = "Frequencies",
title = 'Histogram of waiting times'
)
ggplotly(gg)
})
}
shinyApp(ui = ui, server = server)