library(shiny)
library(ggplot2)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput(
"bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
p <- ggplot(faithful, aes(waiting)) + theme_bw() +
geom_histogram(
aes(y =..density..),
breaks=bins,
col="darkgray",
fill="red",
alpha = .2) +
#geom_density(col=2) +
#ggtitle("Histogram") +
labs(x="waiting", y="Freq")
print(p)
})
}
# Run the application
shinyApp(ui = ui, server = server)
https://shiny.posit.co/r/articles/build/layout-guide/ Build > Frontend> User interface> Application layout guide JANUARY 10, 2024 Overview Shiny apps use Bootstrap, an extremely popular HTML/CSS framework, (though no prior experience with Bootstrap is necessary).As a result, the best way to Read more…
Warning in …. :the condition has length > 1 and only the first element will be used comparing a vector with a scalar=> R automatically takes the first element of var