Skip to content

Instantly share code, notes, and snippets.

@shaun-jacks
Created February 18, 2019 20:01
Show Gist options
  • Save shaun-jacks/3677fd8ebf2bc271ae8cd90c0bbaddd0 to your computer and use it in GitHub Desktop.
Save shaun-jacks/3677fd8ebf2bc271ae8cd90c0bbaddd0 to your computer and use it in GitHub Desktop.
Shiny Dashboard Example using code from shiny dashboard website Tutorial
## app.R ##
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
)
## Body content
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment